-
-
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
Labels
Comments
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: