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

Documentation for setupFile configuration option seems misleading #7174

Closed
bambielli opened this issue Oct 16, 2018 · 4 comments
Closed

Documentation for setupFile configuration option seems misleading #7174

bambielli opened this issue Oct 16, 2018 · 4 comments

Comments

@bambielli
Copy link
Contributor

🐛 Bug Report

The documentation for the setupFile configuration option is misleading.

Here's a link to the documentation.

It states that the setupFile will be run once per test, however it appears that the setupFile runs once per test file.

To Reproduce

Add a setupFile to your jest repository, with a console.log statement in it so you can see when it runs.

You'll notice that the console.log statement prints once per test file (test suite) in your repository, not once per test as the documentation states.

Expected behavior

Per the setupFile documentation, I would expect the setupFile to run once per test, instead of once per test file.

Link to repl or repo (highly encouraged)

Here is a link to a repo with a repro

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.4
    CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
  Binaries:
    Node: 10.0.0 - ~/.nvm/versions/node/v10.0.0/bin/node
    Yarn: 1.6.0 - /usr/local/bin/yarn
    npm: 6.4.0 - ~/.nvm/versions/node/v10.0.0/bin/npm
  npmPackages:
    jest: 23.6.0 => 23.6.0

I'd be happy to make a PR to fix the docs if others agree it is unclear. Thanks for building / maintaining Jest! It is my favorite JS testing option by far, and I am slowly converting my coworkers over to it :)

@thymikee
Copy link
Collaborator

We're making some changes to setupFiles et al., so we could squeeze it here: #7119. Can you comment there?

@rickhanlonii
Copy link
Member

For now it probably makes sense to update the docs to say

each setupFile will be run once per test file, before the environment is setup"

@bambielli
Copy link
Contributor Author

I'll open a PR tonight.

bambielli added a commit to bambielli/jest that referenced this issue Oct 17, 2018
…clarity around expected setupfile behavior
bambielli added a commit to bambielli/jest that referenced this issue Oct 17, 2018
…clarity around expected setupfile behavior
rickhanlonii pushed a commit that referenced this issue Oct 17, 2018
@github-actions
Copy link

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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants