Local interceptors not working when using vi.mock
in Vitest browser mode
#537
Labels
bug
Something isn't working
vi.mock
in Vitest browser mode
#537
Prerequisites
Operating system
Ubuntu 24.04
Runtime
Node.js
Runtime version
22.13.1
Zimic version
0.12.3
Reproduction repository
https://github.com/diego-aquino/zimic-vi-mock-issue
Reproduction steps
pnpm install
pnpm test
Current behavior
The example test contains a simple fetch and a corresponding interceptor. However, the fetch fails with a network error. The problem appears to be related to using
vi.mock
, because commenting that line makes the test pass.I suspect the cause are the changes introduced in the latest version of MSW. Vitest browser comes with an embedded MSW instance, likely used to mock imports when
vi.mock
is applied. However, Zimic's internal MSW version is not the latest because not all of our tests pass due to mswjs/msw#2146.Expected behavior
Zimic should be able to intercept requests even if
vi.mock
is being used. We'll probably have to upgrade MSW to its latest version in #423. To fix the failing tests, we can use a tool such as patch-package to patch mswjs/msw#2146 with a workaround, while it is not fixed in MSW itself.The text was updated successfully, but these errors were encountered: