Skip to content

Documentation for setupFile configuration option seems misleading #7174

Closed
@bambielli

Description

@bambielli

🐛 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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions