improved error msg on toBeRehectedWithError and all other built-in async matchers
This commit is contained in:
@@ -38,6 +38,8 @@ describe('toBePending', function() {
|
|||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(f).toThrowError('Expected toBePending to be called on a promise.');
|
expect(f).toThrowError(
|
||||||
|
`Expected toBePending to be called on a promise but was on a ${typeof actual}.`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ describe('toBeRejected', function() {
|
|||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(f).toThrowError('Expected toBeRejected to be called on a promise.');
|
expect(f).toThrowError(
|
||||||
|
`Expected toBeRejected to be called on a promise but was on a ${typeof actual}.`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(f).toThrowError(
|
expect(f).toThrowError(
|
||||||
'Expected toBeRejectedWithError to be called on a promise.'
|
`Expected toBeRejectedWithError to be called on a promise but was on a ${typeof actual}.`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ describe('#toBeRejectedWith', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(f).toThrowError(
|
expect(f).toThrowError(
|
||||||
'Expected toBeRejectedWith to be called on a promise.'
|
`Expected toBeRejectedWith to be called on a promise but was on a ${typeof actual}.`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ describe('toBeResolved', function() {
|
|||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(f).toThrowError('Expected toBeResolved to be called on a promise.');
|
expect(f).toThrowError(
|
||||||
|
`Expected toBeResolved to be called on a promise but was on a ${typeof actual}.`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ describe('#toBeResolvedTo', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(f).toThrowError(
|
expect(f).toThrowError(
|
||||||
'Expected toBeResolvedTo to be called on a promise.'
|
`Expected toBeResolvedTo to be called on a promise but was on a ${typeof actual}.`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ getJasmineRequireObj().toBePending = function(j$) {
|
|||||||
return {
|
return {
|
||||||
compare: function(actual) {
|
compare: function(actual) {
|
||||||
if (!j$.isPromiseLike(actual)) {
|
if (!j$.isPromiseLike(actual)) {
|
||||||
throw new Error('Expected toBePending to be called on a promise.');
|
throw new Error(
|
||||||
|
`Expected toBePending to be called on a promise but was on a ${typeof actual}.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const want = {};
|
const want = {};
|
||||||
return Promise.race([actual, Promise.resolve(want)]).then(
|
return Promise.race([actual, Promise.resolve(want)]).then(
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ getJasmineRequireObj().toBeRejected = function(j$) {
|
|||||||
return {
|
return {
|
||||||
compare: function(actual) {
|
compare: function(actual) {
|
||||||
if (!j$.isPromiseLike(actual)) {
|
if (!j$.isPromiseLike(actual)) {
|
||||||
throw new Error('Expected toBeRejected to be called on a promise.');
|
throw new Error(
|
||||||
|
`Expected toBeRejected to be called on a promise but was on a ${typeof actual}.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return actual.then(
|
return actual.then(
|
||||||
function() {
|
function() {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) {
|
|||||||
compare: function(actualPromise, expectedValue) {
|
compare: function(actualPromise, expectedValue) {
|
||||||
if (!j$.isPromiseLike(actualPromise)) {
|
if (!j$.isPromiseLike(actualPromise)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Expected toBeRejectedWith to be called on a promise.'
|
`Expected toBeRejectedWith to be called on a promise but was on a ${typeof actualPromise}.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
|||||||
compare: function(actualPromise, arg1, arg2) {
|
compare: function(actualPromise, arg1, arg2) {
|
||||||
if (!j$.isPromiseLike(actualPromise)) {
|
if (!j$.isPromiseLike(actualPromise)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Expected toBeRejectedWithError to be called on a promise.'
|
`Expected toBeRejectedWithError to be called on a promise but was on a ${typeof actualPromise}.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ getJasmineRequireObj().toBeResolved = function(j$) {
|
|||||||
return {
|
return {
|
||||||
compare: function(actual) {
|
compare: function(actual) {
|
||||||
if (!j$.isPromiseLike(actual)) {
|
if (!j$.isPromiseLike(actual)) {
|
||||||
throw new Error('Expected toBeResolved to be called on a promise.');
|
throw new Error(
|
||||||
|
`Expected toBeResolved to be called on a promise but was on a ${typeof actual}.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return actual.then(
|
return actual.then(
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
|||||||
return {
|
return {
|
||||||
compare: function(actualPromise, expectedValue) {
|
compare: function(actualPromise, expectedValue) {
|
||||||
if (!j$.isPromiseLike(actualPromise)) {
|
if (!j$.isPromiseLike(actualPromise)) {
|
||||||
throw new Error('Expected toBeResolvedTo to be called on a promise.');
|
throw new Error(
|
||||||
|
`Expected toBeResolvedTo to be called on a promise but was on a ${typeof actualPromise}.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prefix(passed) {
|
function prefix(passed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user