Skip to content
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

Can't match the handler in tests in nuxt 3 app using useFetch composable #2215

Open
4 tasks done
andreimakushkin opened this issue Jul 23, 2024 · 1 comment
Open
4 tasks done
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node

Comments

@andreimakushkin
Copy link

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 18 or higher

Node.js version

v20.11.1

Reproduction repository

https://github.com/andreimakushkin/nuxt3-msw

Reproduction steps

I've created an Example vue component with test for it, the component use useFetch composable to call an API, but it doesn't work in test. The test just fails without any errors. MSW server doesn't intercept the call.

In order to run test, use command npm run test

await useFetch('/api/example'); // Doesn't match the handler
await useFetch('api/example'); // Matches the handler, but the app doesn't work

Current behavior

await useFetch('/api/example'); // Doesn't match the msw handler

Expected behavior

await useFetch('/api/example'); // Should match the msw handler

@andreimakushkin andreimakushkin added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node labels Jul 23, 2024
@shunnNet
Copy link

@andreimakushkin Hello, I have created a Nuxt module called nuxt-msw which should be able to address the issue you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node
Projects
None yet
Development

No branches or pull requests

2 participants