Testing For Specific Properties Of Rejected Promises, With Mocha And Chai-as-promised
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 shou
Solution 1:
I think rejectedWith() handler has some issues. But you can do like this:
promiseOfUsers.should.be.rejected.and.eventually.have.property("status",401)
Solution 2:
If you want to check if your promised was rejected and check the resulting object (aka the reason):
return fooPromise.should.be.rejected.and.eventually.deep.equal({
'x': 1,
'y': 1,
'z': 2
})
You can change deep.equal
to the any of the usual other chai
matchers.
Note: This is an extension of @sertug's answer and hopefully will be useful for others coming here who looking for this.
Post a Comment for "Testing For Specific Properties Of Rejected Promises, With Mocha And Chai-as-promised"