-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Support jest globalSetup #4393
Comments
@DuskLoop I think |
Maybe it would be sufficient to use a global flag in if (!global.initializedTests) {
// do something
global.initializedTests = true;
} I'm not 100% sure but I think |
@gaearon This code:
prints for every test file and no difference in performance |
@Stupidism I tried running tests with Looks like |
This is an easy change in one file: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/scripts/utils/createJestConfig.js Current:
Changed:
One the keys are allowed to pass through, you can just specify these in your package.json jest:{} entry (or wherever). |
That sounds fine to support out of the box. I'll add it. |
@gaearon , curious as to why certain Jest config options are supported and others are not? I want to use the Jest |
@pakaplace if you customize your CRA with craco you could do it. Here's a sample module.exports = {
jest: {
configure: {
preset: "jest-puppeteer"
}
}
}; Hope this helps! |
Is this a bug report?
No
Problem
I have some setup code that I want to run once before all tests. If I run the code in setupTests.js it will run before every test which slows down the total test time alot.
Jest seems to have an option for this: https://facebook.github.io/jest/docs/en/configuration.html#globalsetup-string
But when I add this option in my package.json jest config section I get message:
These options in your package.json Jest configuration are not currently supported by Create React App:
• globalSetup
Would be nice to see this option supported by Create React App or if someone could provide a workaround for this issue.
The text was updated successfully, but these errors were encountered: