-
-
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
feat: add support for snapshot matchers in concurrent tests #14139
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
982e485
to
fa25874
Compare
Hey! I landed #14045 which aims to solve the same issue, albeit with a new matcher. Do you think this PR adds additional value? |
To add my two cents: this PR looks like a better solution than new matcher.
It is a pity that so much work went into |
I tend to agree with @mrazauskas. The fact that the same matcher can be used in concurrent and normal tests and that you don't need to give it an explicit name makes it more appealing to me. |
Yeah, I'm kinda convinced by that argument 😅 |
i bumped my jest to 29.6.0 and there are multiple concurrent tests in multiple describes in the same file, I think I'm still getting random snapshot names. Is this a known issue or an expected behaviour? |
#14335 is not released yet - might be it |
Ohh I see. Thanks a lot. Can't wait for the release. |
@nutchanon-c new release is out - can you confirm it fixes your issue? If not, please open a new issue 🙂 |
It seems to fix the issue so far! If any new issues come up, I'll open a new issue later. Thank you very much! |
Why is
It just caused my non-node project to explode with type errors since Jest types are global and |
I added it because |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This implements support for snapshot matchers in concurrent tests. The long-standing issue with this has been rooted in the fact that because concurrent tests run in parallel there is no concept of a single currently running test and so jest-snapshot is not able to get this information from a global state object.
This problem can however be solved with
AsyncLocalStorage
, which is an object that can hold different values for different async contexts. Each concurrent test runs in its own async context and when asking for a value from the storage, gets a result that is unique to it.Support is added only to jest-circus.
Test plan
There is a new integration test for this use-case.
Fixes #2180.
Fixes #5801.