Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running Cypress tests in Electron, MSW activation occurs after test completion, causing tests to fail #2114

Open
4 tasks done
jolientb opened this issue Mar 28, 2024 · 0 comments
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser

Comments

@jolientb
Copy link

Prerequisites

Environment check

  • I'm using the latest msw version
  • 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.

msw-cypress

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).

@jolientb jolientb added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser labels Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser
Projects
None yet
Development

No branches or pull requests

1 participant