vitest-dev / vitest-dev/vitest

coverage broken in browser mode in a rush/pnpm monorepo

Open
#8,656 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat: browser pending triage
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

When running with coverage

TypeError: Failed to fetch dynamically imported module: http://localhost:63315/@id/@vitest/coverage-v8/browser?import

It fails to import the module, most likely because in this setup modules are symlinked (i think)

Image
Reproduction

https://github.com/Georgegriff/vitest-rush-coverage-repro

Clone repo

npm install -g @microsoft/rush

rush update

cd apps/vitest-react-app

rush test:run --coverage

Coverage fails to generate

If i delete the node modules, and in apps/vitest-rect-app run npm install instead and run

npm run test:run -- --coverage it works, further suggesting this is a bug resolving symlinks somewhere in vitest with coverage providers

System Info
System:
    OS: macOS 15.7.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 122.81 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 11.5.1 - ~/.nvm/versions/node/v20.17.0/bin/npm
    pnpm: 10.17.1 - ~/.nvm/versions/node/v20.17.0/bin/pnpm
    bun: 1.0.12 - ~/.bun/bin/bun
    Deno: 1.34.3 - /opt/homebrew/bin/deno
  Browsers:
    Edge: 140.0.3485.94
    Safari: 26.0.1
  npmPackages:
    @vitejs/plugin-react-swc: ^3.11.0 => 3.11.0 
    @vitest/browser: ^3.2.4 => 3.2.4 
    @vitest/coverage-v8: ^3.2.4 => 3.2.4 
    playwright: ^1.55.1 => 1.55.1 
    vite: ^6.0.0 => 6.3.6 
    vitest: ^3.2.4 => 3.2.4 
    vitest-browser-react: ^1.0.1 => 1.0.1
Used Package Manager

pnpm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Georgegriff/vitest-rush-coverage-repro repository and run the documented Rush coverage command in apps/vitest-react-app, then compare it with the working npm installation path. Trace browser coverage's dynamic import of @vitest/coverage-v8/browser under the symlinked monorepo setup; done means coverage generates successfully with Rush and pnpm.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, typescript, vite
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.