Integration testing with NextJS 12+ Middleware #41262
Unanswered
kristojorg
asked this question in
Help
Replies: 3 comments
-
I have opened a ticket with MSW mswjs/msw#1429 to support the edge runtime. They have said this is not on their roadmap currently as there is no standard edge runtime. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Is there any news regarding this? i am running in the same issue :/ |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi I know it's late, but do you have an example of how you achieved interception on server side call (getInitialProps)? I am still here struggling to do that, this doesn't work for me |
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
Uh oh!
There was an error while loading. Please reload this page.
-
I have an app that performs authentication in NextJS 12 Middleware which I would like to integration test using Cypress. I can successfully intercept requests to external APIs using mock-service-worker on both the client side and server side. However, I'm not able to intercept fetch requests made by my
middleware.ts
file. This means that I cannot mock out authentication, and my tests have to actually sign a real user in and depend on third party functionality.I am wondering if anyone has had success intercepting requests from NextJS middleware? I have been trying to do this by running my NextJS app programmatically when starting Cypress, and starting a MSW interception service at the same time in both the client and the server. I can intercept requests from
getStaticProps
, but not frommiddleware.ts
. Any ideas?Beta Was this translation helpful? Give feedback.
All reactions