improved error msg on toBeRehectedWithError and all other built-in async matchers

This commit is contained in:
Andrei D
2024-12-22 17:43:47 +02:00
parent 1f1e1209d2
commit a1591da25d
12 changed files with 26 additions and 12 deletions

View File

@@ -38,6 +38,8 @@ describe('toBePending', function() {
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}.`
);
});
});

View File

@@ -28,6 +28,8 @@ describe('toBeRejected', function() {
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}.`
);
});
});

View File

@@ -232,7 +232,7 @@ describe('#toBeRejectedWithError', function() {
}
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}.`
);
});
});

View File

@@ -83,7 +83,7 @@ describe('#toBeRejectedWith', function() {
}
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}.`
);
});
});

View File

@@ -35,6 +35,8 @@ describe('toBeResolved', function() {
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}.`
);
});
});

View File

@@ -93,7 +93,7 @@ describe('#toBeResolvedTo', function() {
}
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}.`
);
});
});