Skip to content

Vitest browser mode tests always fail when using mixed-typed workspaces #3577

@jaa134

Description

@jaa134

Describe the bug

I have a monorepo and I am taking advantage of Vitest workspaces. One workspace uses browser mode and the other workspace does NOT use browser mode.

When I run tests from the project root, the normal tests run fine, but browser tests always fail. The browser test can be extremely simple like expect(true).toBeTruthy() and it still fails. However, if I run the tests from the individual workspaces instead of the project root, then the tests always execute and succeed.

This seems to be a regression of the change made from this issue: #3363. I was able to verify this fix in the next release of Vitest.

Since then, I have upgraded to Vitest v0.32.0 and switched to using v8 as a coverage provider. Even If I switch back to c8, the bug still occurs. I should also note that running tests and collecting coverage or not collecting coverage makes no difference in the outcome.

Reproduction

https://stackblitz.com/edit/vitest-browser-mode-bug-2?file=package.json

System Info

- pnpm: v8.4.0
- vitest: ^0.32.0
- playwright: ^1.35.0
- pnpm workspaces
- vitest workspaces

  System:
    OS: macOS 11.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 2.85 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
  Browsers:
    Chrome: 114.0.5735.106
    Firefox: 111.0
    Safari: 14.1.2
  npmPackages:
    @vitest/browser: ^0.32.0 => 0.32.0 
    @vitest/coverage-v8: ^0.32.0 => 0.32.0 
    @vitest/utils: ^0.32.0 => 0.32.0 
    vitest: ^0.32.0 => 0.32.0

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions