msw
msw copied to clipboard
When running Cypress tests in Electron, MSW activation occurs after test completion, causing tests to fail
Prerequisites
- [X] I confirm my issue is not in the opened issues
- [X] I confirm the Frequently Asked Questions didn't contain the answer to my issue
Environment check
- [X] I'm using the latest
mswversion - [X] I'm using Node.js version 18 or higher
Browsers
No response
Reproduction repository
https://github.com/jolientb/msw-cypress.git
Reproduction steps
- Run: npx cypress open
- Choose E2E testing
- Choose the Electron browser
- Click on: Start e2e Testing in Electron
- Click on: spec.cy.ts
Current behavior
Cypress test fails in Electron browser When you run the cypress e2e test in the Electron browser for the first time the test fails, because msw is only enabled after the test has finished. When running the test again in the same session, msw is enabled on time and the test does succeed.
Ps. When running the test in the chrome browser or in Electron 118 (headless) msw is enabled on time, and the test succeeds. And I tried adding an await before worker.start(), but this doesn't solve the problem.
Expected behavior
Electron browser: MSW should be enabled before test is completed When you run the cypress e2e test in the Electron browser for the first time, msw should be enabled before the test finishes and the test should succeed (just like in the Chrome browser).