-
Notifications
You must be signed in to change notification settings - Fork 211
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 @jest/globals for schematics #1324
base: master
Are you sure you want to change the base?
Conversation
I wonder if wouldn't be better if we only add those import statements if |
I'm not sure there's an easy way to know it, considering that jest can be configured with a javascript file that can be dynamic, and we probably want to avoid running it to discover what config the user has. What would be the main motivation to not use this import? |
not having those globals isn't common (not yet, at least). And the jest docs has a note regarding that
I'm unsure on what that means, in practice tho. The only way I can think of is by adding yet another flag to the schematics to opt-in to this change. Then the CLI would define the value of that flag at runtime. Since the jest config file can be defined by the end user (ie, it could have any name), this solution won't work for everyone. But if Kamil agree that we could start having this import, it's fine. I like this new version more. |
That comment means that if you do not use I guess that this import will always work, no matter the value of the config or what runner is used. |
Is Jest about to drop the auto-globals-injection feature any time soon? |
I'm not sure about that, but there are already certain cases where the globals are not injected anymore (when the runner is different or when you have ESM enabled) that's also why I discovered it. |
Do those imports works when injectGlobals is true? |
Yes |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #1942
What is the new behavior?
This PR adds the jest/globals for every generated file
Does this PR introduce a breaking change?
Other information