toBeRejectedWithError can expect the error to be Error, not just a subtype

This commit is contained in:
Steve Gravrock
2019-09-06 14:17:52 -07:00
parent 5a219da848
commit 2d3ac38df8
3 changed files with 22 additions and 6 deletions
@@ -27,6 +27,21 @@ describe('#toBeRejectedWithError', function () {
});
});
it('passes when Error matches and is exactly Error', function() {
jasmine.getEnv().requirePromises();
var matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(jasmineUnderTest.matchersUtil),
actual = Promise.reject(new Error());
return matcher.compare(actual, Error).then(function (result) {
expect(result).toEqual(jasmine.objectContaining({
pass: true,
message: 'Expected a promise not to be rejected with Error, but it was.'
}));
});
});
it('passes when Error message matches a string', function () {
jasmine.getEnv().requirePromises();