-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Support for Error.cause in jest.Matchers #12053
Comments
It would also be great to support asserting all the chained error-cause messages at once, maybe with I wrote this temporarily (facebook/docusaurus#8234) because I'm not sure how to assert this with Jest in a better way: it('docs with invalid id', async () => {
const error = await testUtils.getProcessDocFileError("some/fake/path");
expect(error.message).toMatchInlineSnapshot(
`"Can't process doc metadata for doc at path path=some/fake/path in version name=current"`,
);
expect(error.cause).toBeDefined();
expect(error.cause!.message).toMatchInlineSnapshot(
`"Document id "Hello/world" cannot include slash."`,
);
}); |
PR very much welcome for this! 🙂 Some discussion in #13260 as well |
I will try this ✋ |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Error.cause
has been freshly added to the JavaScript language (https://tc39.es/ecma262/#sec-error-message) and makes chaining errors easier than ever.Motivation
Error.cause
is a very useful feature. It would be very useful if it would be possible to testError.cause
with jestRelated: #11935
Example
toThrowError
could acceptcause
as an additional property:Pitch
It is a core feature of the javascript language and would be very useful.
The text was updated successfully, but these errors were encountered: