Skip to content

beforeEach/beforeAll in setup file gets executed only for one test suite #11073

Description

@adamsol

Describe the bug

When:

  • beforeEach/beforeAll is present in a setup file
  • the setup file is referenced in setupFiles without extension
  • the configuration contains isolate: false and maxWorkers: 1 (which I'm using to speed up the tests)

then the callback runs only for one test file (apparently one that happens to be executed first) instead of for all files.

In the repro, observe the console output: beforeEach is printed only once instead of 2 times.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-bw2va5tg?file=vite.config.js

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 22.22.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vitest: 4.1.11 => 4.1.11

Used Package Manager

npm

Validations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo