vitest-dev / vitest-dev/vitest

Vitest browser mode breaks ensureFileWatched (commonly breaking pnp virtual)

Open
#7,356 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat: browser feat: workspace p3-minor-bug
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

Files in vitest that would normally be watched by vitest here:

https://github.com/vitejs/vite/blob/30194fa1e41dda6470aa20f2bb34655c4bfd9cd1/packages/vite/src/node/server/transformRequest.ts#L286-L292

are not watched when running in browser mode, as environment.pluginContainer.watcher is a no-op watcher. This will apply in fact to any attempt to watch a file via the PluginContainer.

Reproduction

https://github.com/mrginglymus/vitest-pnp

System Info
System:
    OS: Windows 10 10.0.19045
    CPU: (24) x64 Intel(R) Core(TM) i9-10920X CPU @ 3.50GHz
    Memory: 20.97 GB / 63.80 GB
  Binaries:
    Node: 22.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 4.5.2 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.146)
    Internet Explorer: 11.0.19041.4355
Used Package Manager

yarn

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 browser-mode environment.pluginContainer.watcher behavior and compare it with Vite's transformRequest.ts lines 286-292. Use the vitest-pnp reproduction to verify the failure, and consider the work complete when files passed through the PluginContainer are watched in browser mode and the reproduction works.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.