Include rejection details in failure messages for toBeResolved and toBeResolvedWith

[#178559119]
This commit is contained in:
Steve Gravrock
2021-06-21 16:43:51 -07:00
parent 163f93d6ff
commit 5862b22aef
6 changed files with 51 additions and 19 deletions

View File

@@ -15,12 +15,19 @@ describe('toBeResolved', function() {
it('fails if the actual is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter([])
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil),
actual = Promise.reject('AsyncExpectationSpec rejection');
actual = Promise.reject(new Error('AsyncExpectationSpec rejection'));
return matcher.compare(actual).then(function(result) {
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
expect(result).toEqual({
pass: false,
message:
'Expected a promise to be resolved but it was rejected ' +
'with Error: AsyncExpectationSpec rejection.'
});
});
});

View File

@@ -19,14 +19,15 @@ describe('#toBeResolvedTo', function() {
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = Promise.reject('AsyncExpectationSpec error');
actual = Promise.reject(new Error('AsyncExpectationSpec error'));
return matcher.compare(actual, '').then(function(result) {
expect(result).toEqual(
jasmine.objectContaining({
pass: false,
message:
"Expected a promise to be resolved to '' but it was rejected."
"Expected a promise to be resolved to '' but it was rejected " +
'with Error: AsyncExpectationSpec error.'
})
);
});