vitest-dev / vitest-dev/vitest
[browser] mocking + cacheDir fails for some cacheDirs
Open
Nobody has claimed this yet.
feat: browser
p3-minor-bug
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
When using vitest browser mode, mocking does not work if cacheDir is set to a subparent directory.
This DOES work properly in node mode.
Reproduction
https://github.com/meesvandongen/vitest-repro
npm run test:child:browser // success
npm run test:parent:browser // fails
npm run test:parent:node // success
System Info
browser = chrome, playwright; did not test with other setups
System:
OS: macOS 15.1
CPU: (16) arm64 Apple M3 Max
Memory: 7.45 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
pnpm: 9.4.0 - /opt/homebrew/bin/pnpm
bun: 1.1.31 - ~/.bun/bin/bun
Browsers:
Chrome: 131.0.6778.69
Edge: 131.0.2903.48
Safari: 18.1
npmPackages:
@vitest/browser: ^2.1.5 => 2.1.5
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked minimal reproduction and run npm run test🧒browser, npm run test:parent:browser, and npm run test:parent:node. Compare the browser-mode parent and child cases around cacheDir and mocking; done means the parent browser command succeeds while the existing child-browser and parent-node cases continue to pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- playwright, typescript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100