vitest-dev / vitest-dev/vitest
MSW does not intercept all requests
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
When running outside of browser mode, Vitest returns different objects from import * as https from 'node:https' and require('node:https'). MSW expects these to be the same object, and only patches one of them.
This issue does not occur when running outside of Vitest, in Nodejs directly.
Reproduction
https://github.com/maxburs/vitest-msw-bug-reproduction (LLM authored)
System Info
- Vitest 4.1.9
- MSW 2.14.6
- Node.js 22.22.3
- macOS 26.5.2
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 maxburs/vitest-msw-bug-reproduction and compare the import * as https from 'node:https' and require('node:https') entry points under Vitest and direct Node.js. Trace how MSW patches each object and add coverage showing that requests through both forms are intercepted consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100