-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use with msw
to mock requests
#775
Comments
Linking unjs/ofetch#295 here as well |
As a workaround you can try to use |
Just a shot in the dark, but it seems that the addition of v3.10.0...v3.11.0#diff-aed062a1fdd005bf79a0cf1ce9791008fa96eb4b91dbcd9e85d1820b6257450a Edit: I found a workaround to fix our setup:
|
@bcorey85 Where would you add that workaround? |
@david-mears-2 It's ultimately in my Vitest setupFiles. I have it wrapped in a function that I call when my test environment spins up:
|
Hello, I have created a Nuxt module called |
This is now working. You only need to overwrite
|
Environment
Reproduction
https://stackblitz.com/~/github.com/rinux55/nuxt-fetch
See
app.test.ts
. In thetest/setup.ts
andtest/server.ts
there is anmsw
server being set up with a mocked endpoint.Describe the bug
To mock requests made using
$fetch
anduseFetch
, I expect to be able to use a utility likemsw
.Unfortunately, this doesn't seem to work in combination with
@nuxt/test-utils
.I've created a reproduction where you can see that
globalThis.fetch
is mocked just fine, butuseFetch
orfetch
is not:https://stackblitz.com/~/github.com/rinux55/nuxt-fetch
Any help with this would be greatly appreciated.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: