I\'m struggling to work out the best way to verify that a promise is rejected in a Mocha test while using async/await.
Here\'s an example that works, but I dislike t
You can use async/await
and should
for simple verification
it('should not throw an error', async () => {
try {
let r = await wins();
r.should.equal('Winner');
} catch (error) {
error.should.be.null(); //should.not.exist(error) can also be used
}
});
it('throws an error', async () => {
try {
await fails();
} catch (error) {
error.should.be.Error();
error.should.have.value("message", "Contrived Error");
}
});