How can you mock the internal fetch of your route handler? #1063
Unanswered
lucasmotta
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hey there! Unfortunately, it seems like you're running into the incompatibility between MSW and the Next.js App Router. It looks thorny, but there are some ways you can restore the Native/MSW fetch if you don't want to use Next's. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there, thanks for such an amazing library. I'm having some issues trying to mock the response of a fetch used inside the route handler.
Let's say I've a route handler like this (simplified for demo purposes):
How can I mock the result of that fetch used inside my handler, so I can test different redirects?
I tried using msw to setup some mock results, but that does not seem to do anything, which I believe is due to how Next mocks the fetch globally.
I would love some guidance as I've been knocking my head trying to test route handlers.
Beta Was this translation helpful? Give feedback.
All reactions