I use chai-as-promised library with promise generated by the q library. This simple test case should work (the promise must be rejected) or i misunderstand promise feature?
bdd.it("Test rejection", function () {
var promise = q.promise(function (resolve, reject, notify) {
reject(new Error("test"));
}).then(function () {
// Nothing to do
});
promise.should.be.rejectedWith(Error);
return promise;
});
This test fail with Error: test (I use Intern as unit test library) althought the below test pass:
bdd.it("Test rejection", function () {
var promise = q.promise(function (resolve, reject, notify) {
reject(new Error("test"));
}).should.be.rejectedWith(Error);
return promise;
});