I am trying to test the specifics of a rejected Promise, using Chai-as-Promised, Mocha, and the "should" dialect. Promises are implemented by bluebird.
This works fine:
it('it should be rejected when given bad credentials', function () {
var promiseOfUsers = db.auth("bad", "credentials").getUsers();
return promiseOfUsers.should.eventually.be.rejectedWith(Error)
});
There is a "status" property on that error. I would like to assert that status is 401
This does not work:
it('it should be rejected when given bad credentials', function () {
var promiseOfUsers = db.auth("bad", "credentials").getUsers();
return promiseOfUsers.should.eventually.be.rejectedWith(Error)
.that.has.property('status')
.that.equals(401)
});
It seems that any attempt to assert without referencing "rejected" or rejectedWith(Error), fails and just prints the error out to the console.
How can I delve into the reason for the rejection?