-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Bug]: toThrow
does not fail test on mismatch of Error#cause
#15316
Comments
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
Folks, there's a PR and everything, and it even protects against circular references. Let's land it! |
Version
30.0.0-alpha.6
Steps to reproduce
Expected behavior
The test should fail, owing to the mismatch of
Error#cause
.Actual behavior
The test passes.
Additional context
This is a re-file of #15111 which was auto-closed for inactivity. Updated to note that this is still a problem in Jest v30.
This appears to be because Jest only does cause-matching when the
cause
property is an instance ofError
.https://github.com/jestjs/jest/blob/main/packages/expect/src/toThrowMatchers.ts#L481-L483
This is inappropriate, since the value of
cause
is allowed to be any type.Environment
The text was updated successfully, but these errors were encountered: