MSW leaves cypress component test runner in a loop
See original GitHub issueDescribe the bug
Cypress 7 recently released an interesting feature called component test runner. It allows to mount a component and run it in isolation, rather than having to run the entire application. I was trying to use it with MSW (which would be awesome!), but for some reason, starting the service worker makes the test behave weirdly, becoming flaky, sometimes looping and causing trouble.
Environment
msw: 0.28.2
nodejs: 14.14.0
npm: 6.4.8
- browser: Chromium opened by cypress
To Reproduce
Steps to reproduce the behavior:
before, check this repro: https://github.com/yannbf/msw-cypress-component-issue
- yarn
- yarn cy
- Select Login.test.jsx
- Check the comments in https://github.com/yannbf/msw-cypress-component-issue/blob/main/src/components/Login.test.jsx#L9. As soon as you remove the
start
of the service worker, the tests flow naturally. When you add them, there’s something weird that results in cypress runner looping.
Expected behavior
MSW should not impact cypress
Screenshots
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:28 (10 by maintainers)
Top Results From Across the Web
A brand new website interface for an even better experience!
MSW leaves cypress component test runner in a loop.
Read more >Introducing the Cypress Component Test Runner
We're proud to announce the alpha release of Cypress's dedicated Component Test Runner. It's a brand new test runner that's designed to replace ......
Read more >Mock Service Worker on Twitter: "@sunpietro Hello, Piotr. We could ...
Describe the bug Cypress 7 recently released an interesting feature called component test runner. It allows to mount a component and run it...
Read more >Loading fixture with component test - cypress - Stack Overflow
Alises are cleared down between tests. You can change the hook to beforeEach() to allow all tests to see the data. Note that...
Read more >Avoid Nesting when you're Testing - Kent C. Dodds
Here's a React component that I want to test: ... For our simple Login component here, I'd probably leave the test as-is, but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having the same problem, and none of the above workarounds have worked for me. I’d really love to be able to use MSW in my Cypress tests, is there any progress on this issue?
Ok thanks @kettanaito and @the-ult. I’ll poke around Cypress a bit, it probably won’t be until next week though. I’m fairly sure something is getting muddled up in the routing for CT.
The CT specific routes are here https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/routes-ct.ts The shared routes are https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/routes.ts
Small files, so this should not be too hard to debug.