Replies: 1 comment
-
You can call // your-app.js
const worker = setupWorker(...handlers)
window.worker = worker // your.test.js
before(async () => {
await cy.window().then((win) => {
// Resetting handlers is a synchronous action.
win.worker.resetHandlers()
})
}) The usage is the same as with the runtime request handlers with Cypress. |
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
-
I am mocking GraphQL requests made server side with Next.js
getServerSideProps
hook viasetupServe(...handlers)
following the example provided by Next.js https://github.com/vercel/next.js/tree/canary/examples/with-msw.I would like to reset a specific resolver before each Cypress test to test different data scenarios. Is there a way to trigger
server.resetHandlers
from abefore
hook into a Cypress test?I have found this stack overflow answer https://stackoverflow.com/questions/47631821/mocking-server-for-ssr-react-app-e2e-tests-with-cypress-io using MockTTP.
Is it possible to do the same with msw?
Beta Was this translation helpful? Give feedback.
All reactions