-
-
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
toMatchSnapshot does not throw an exception on failure #9107
Comments
The difference in behavior might be a design feature according to the following comment: https://github.com/facebook/jest/blob/master/packages/expect/src/index.ts#L245-L250 |
It somewhat makes sense to get all the failures but the same reason would apply to any matcher. Would it make sense to add an option to Referencing: #5802 |
Thank you for the links. Because the code comment is 3 years old, I am not sure about the effect of a change in behavior. Having said that, #9049 and #9104 throw some new matcher errors for failures caused by incorrect expected, received, or snapshot state It is a hypothesis to explore whether a snapshot assertion fails or throws might affect the count appended to the name to make it unique. If throwing is a problem, then I have made it worse. Research for this issue reminded me is snapshot assertions are added by // Notes a built-in/internal Jest matcher.
// Jest may override the stack trace of Errors thrown by internal matchers. @SimenB do you know about stack trace of Errors for snapshot versus other matchers? Going a bit off issue, my first impression of #5503 is that it seems like an unintended side-effect if it creates asymmetric matchers corresponding to snapshot matchers (because they are external) |
Here is minimal repro that test('toEqual asymmetric toMatchSnapshot', () => {
expect(true).toEqual(expect.toMatchSnapshot());
});
@cpojer Do you have any guidance how deeply for us to solve this side-effect of #5503
|
This issue is stale because it has been open for 1 year 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 has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Whenever I use
toMatchSnapshot ()
as inexpect (val).toMatchSnapshot ()
and that it fails, no exception is being thrown as this is done for other matchers. Not sure if it matters, but I always use async calls.To Reproduce
Expected behavior
An exception is thrown so I can catch it like this is done for other matchers.
envinfo
Using jest v24.7.1 with ts-jest v24.1.0.
The text was updated successfully, but these errors were encountered: