-
-
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
Have separate snapshot files for branching behavior at compile time #1656
Comments
We don't really have a way of doing this on the framework level and I don't think we need to. I recommend you to make your globals injectable and then write your tests like so:
Alternatively, you can also reset modules and redefine your globals:
Both of these options should be sufficient without introducing complexity to Jest. |
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. |
Do you want to request a feature or report a bug?
Feature Request
What is the current behavior?
Currently, I have Webpack inject some global constants at compile time to produce different builds depending on environment. This affects styling, what components are rendered, etc. If I run snapshot tests with these constants in Jest's globals config
"globals": { ... }
, previous snapshots are invalidated whenever I re-run the test with different global values, because the output is different. It would be great if separate snapshot files can be created and be used to check against later snapshot tests based on theglobals
or some other configuration.The text was updated successfully, but these errors were encountered: