[vitest-browser-react] vi.mock()
with spy: true
option breaks MSW interceptors and causes real network requests
#7572
Labels
vi.mock()
with spy: true
option breaks MSW interceptors and causes real network requests
#7572
Describe the bug
When using
vi.mock()
with thespy: true
option on a module that makes network requests, it appears to conflict with MSW interceptors. This causes the tests to bypass the MSW mock handlers and attempt real network requests, which leads to test failures.The issue also has a global effect on the test suite:
vi.mock()
call is scoped to a specific describevi.mock()
call usingdescribe.skip
The issue persists and breaks other tests that depend on MSW interception
Reproduction
Set up MSW to intercept network requests in tests
MSW intercepts requests as expected; tests pass
MSW intercepts requests conflicted; ALL tests fail
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: