You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
diego-aquino
changed the title
Interceptors not working when using vi.mock in Vitest browser mode
Local interceptors not working when using vi.mock in Vitest browser mode
Jan 25, 2025
Since remote interceptors do not use MSW, they are not affected by this issue. Changing from a local to a remote interceptor serves as a current workaround.
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: