MSW fails to intercept GraphQL queries when using vi.mock in Browser Mode #6766
Labels
feat: browser
Issues and PRs related to the browser runner
p3-minor-bug
An edge case that only affects very specific usage (priority)
Describe the bug
I am encountering an issue where MSW is unable to intercept GraphQL queries when using
vi.mock
from Vitest in my test setup.Regardless of which module is being mocked using
vi.mock
, MSW cannot intercept the requests whenvi.mock
is active.Reproduction
A minimal reproduction of the issue can be found here. https://github.com/ytoshiki/repro-msw-vitest-browser
Steps To Reproduce
npm install
to install dependencies.npm run test:browser
to start the test in the browser.components/index.test.ts
, MSW fails to mock the GraphQL queries. However, when pressing therefetch pokemon
button in the browser, the mock works as expected.vi.mock
section in the test file, kill the running task in the terminal, and rerunnpm run test:browser
vi.mock
.System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: