I'm using Mocha and Should.js to test a promise that I am expecting to generate an error.
Because it is a promise, I don't believe I can simply use should.throwError()
. This just means that I would like to fail the unit test in the .catch
block of the promise.
How do I explicitly fail a unit test using without using some sort of stupid hack like 1.should.equal(2)
?
Example Code (Which does not work)
it('should throw an error.', function(done) {
myPromiseGenerator().then(function() {
should.fail();
done();
}).catch(function(e) {
done();
})
}