Mocks fail intermittently when multiple browser tabs are open
See original GitHub issueDescribe the bug
The mocks fail intermittently when multiple browser tabs are open
Environment
msw: 0.15.5
nodejs: 10.19.0
react: 16.13.1
react-scripts: 3.4.1
// create-react-app
Please also provide your browser version.
Chrome 81.0.4044.113 (Official Build) (64-bit) Linux - Ubuntu
To Reproduce
- Have set up
update on reload
for the service worker - Have multiple browser tabs open, eg:
http://localhots:3000/
http://localhost:3000/episode/Fz9eb58992-1e0f-4b2a-ac69-37fce2e934df?section=Storylines
- Have MSW setup with following options:
const options = { serviceWorker: { url: '/mockServiceWorker.js' } }
- Have the following MSW rule:
export default [
rest.get(
`https://example.com/lists/characters/:rdfID`,
(_req, res, { json }) => {
return res(json(characters))
},
),
]
const characters: Character[] = [
{
characterId: 'z9540c2f4-0970-de63-9973-ae9cb4ac31b8',
characterName: 'Pinkie Pie',
},
{
characterId: 'z67416fa2-6883-4c1f-2db9-012984486da6',
characterName: "Rarity",
},
]
- Refresh
http://localhost:3000/episode/Fz9eb58992-1e0f-4b2a-ac69-37fce2e934df?section=Storylines
Expected behavior
https://example.com/list/characters/Fz9eb58992-1e0f-4b2a-ac69-37fce2e934df
Should be mocked, but randomly it’s not.
Workaround
Close all browser tabs but one. This fixes the issue.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:15 (13 by maintainers)
Top Results From Across the Web
How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >Too many browser tabs open - Microsoft Community
I am having slow and freezing problems with edge and firefox browsers. I started opening task manager and checking the browsers.
Read more >Why did my test fail? - Testim overview
Tab not Found. This error occurs when Testim could not find the correct tab for the step to act on. Common Causes: Test...
Read more >Chrome tabs intermittent hang or crash with white screen
An immediate fix to the failed tabs can be to restart the browser, however, after a significant wait, they will regain functionality. Our...
Read more >Why tests pass locally but fail in Jenkins | Object Partners
I've seen this occur when the test assertions are actually completed before the async calls finish. If possible, you should run your assertions ......
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
@VanTanev, thanks for such a detailed debugging and great lead! Happy to hear it works.
@kettanaito It seems to work, thank you for your work!