Do not listen to all messages posted on broswer
See original GitHub issueDescribe the bug
MSW reads all posted messages as MSW messages. However, anything can post a message. In particular, the react dev tools posts messages all the time. With MSW installed, MSW will throw uncaught exceptions.
Environment
msw@0.24.4
nodejs: v14.15.1
npm: 6.14.4
Google Chrome Version 87.0.4280.141 (Official Build) (x86_64) macOS Big Sur 11.1
To Reproduce
Steps to reproduce the behavior:
- Install React Developer Tools
- Run test suite (on a browser) with MSW
- See error in console
Expected behavior
There shouldn’t be any errors.
Screenshots
Here is a screenshot of the failing line in MSW:
And more stack traces (which all seem to be related to react-dev-tools):
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:18 (13 by maintainers)
Top Results From Across the Web
How to stop all your smart devices from listening to you
Open the Settings app. Then, scroll down and tap Facebook. Toggle the green switch next to Microphone to the off position. Another way...
Read more >Window.postMessage() - Web APIs | MDN
A window can listen for dispatched messages by executing the following JavaScript: ... do not add any event listeners for message events.
Read more >Is my phone listening to my conversations?
Ask Help Desk: No, your phone isn't listening to your conversations. ... And is all the anxiety about online privacy really necessary?
Read more >Listen To The Message - Gleb Bahmutov
In this blog post, I will show how to confirm the message was sent when using Cypress end-to-end test runner. The application #....
Read more >Archive or delete messages, calls, or voicemails - Computer
Delete. Important: If you use a Google Voice account with work or school, you may not have this feature. Delete multiple messages.
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
An observation:
The test does not fail because MSW handles all desired requests successfully. The undesired requests (from other sources) throw an exception but it does not affect the outcome of the test.
While it is not blocking test development, it is annoying to see a few unhandled exceptions per test. When you have a codebase with 1k+ tests, this can become overwhelming.
I think that to replicate the issue you can simply call
window.postMessage
on a page of puppeteer usingpage.evaluate