test-utils
test-utils copied to clipboard
Unable to use with `msw` to mock requests
Environment
- Operating System: Darwin
- Node Version: v18.19.1
- Nuxt Version: 3.10.3
- CLI Version: 3.10.1
- Nitro Version: 2.9.3
- Package Manager: [email protected]
- Builder: -
- User Config: devtools
- Runtime Modules: -
- Build Modules: -
Reproduction
https://stackblitz.com/~/github.com/rinux55/nuxt-fetch
See app.test.ts. In the test/setup.ts and test/server.ts there is an msw server being set up with a mocked endpoint.
Describe the bug
To mock requests made using $fetch and useFetch, I expect to be able to use a utility like msw.
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, but useFetch or fetch 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