Skip to content
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

Docs: setupFiles vs setupFilesAfterEnv #9314

Closed
thernstig opened this issue Dec 16, 2019 · 6 comments
Closed

Docs: setupFiles vs setupFilesAfterEnv #9314

thernstig opened this issue Dec 16, 2019 · 6 comments
Labels

Comments

@thernstig
Copy link
Contributor

I am writing this as an issue here as it might potentially be a request for improvements of the docs.

setupFiles and setupFilesAfterEnv has no clear indication as to why both are needed. My investigation seems to show that anything you do in setupFiles might as well equally well be done in setupFilesAfterEnv. setupFilesAfterEnv seems to be the more powerful option as it has more information available and can thus monkey-patch APIs.

@jeysal
Copy link
Contributor

jeysal commented Dec 16, 2019

I imagine setupFiles could capture some globals before the environment modifies them, but I don't know about concrete use cases where only setupFiles works - @SimenB do you know any?

@silvenon
Copy link
Contributor

One very contrived reason I could think of why setting globals in setupFiles is safer is that some library might define a global which conflicts with Jest's globals, so Jest will override it when setting up the framework. If you import this library in setupFilesAfterEnv, you couldn't bring the previous value back.

@thernstig
Copy link
Contributor Author

I assume another reason could be performance?

@github-actions
Copy link

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 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

github-actions bot commented May 4, 2022

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants