Replies: 1 comment
-
Can you share the issue on a codesandbox ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey!
I am trying to use MSW to mock http request made to an API using native fetch (node 20, latest MSW and vitest).
I noticed that request from my code are not intercepted by MSW, but the exact same request made from inside the test code is intercepted (I used the debugging run book). Apparently, in the code we have a nice client wrapper for outside API calls doing something like:
And this runs on importing, and I guess before MSW interceptor is running. When I am changing this to be function:
Everything behave as I expect and MSW is able to intercept the request. I tried putting the
server.listen
in vitest global setup but this didn't help so I am not sure what else I can do. Anyone faced a similar issue?Beta Was this translation helpful? Give feedback.
All reactions