question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do not listen to all messages posted on broswer

See original GitHub issue

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

image

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:

  1. Install React Developer Tools
  2. Run test suite (on a browser) with MSW
  3. See error in console

Expected behavior

There shouldn’t be any errors.

Screenshots

Here is a screenshot of the failing line in MSW:

image

And more stack traces (which all seem to be related to react-dev-tools):

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
juancacommented, Jan 22, 2021

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.

1reaction
marcosvega91commented, Jan 18, 2021

I think that to replicate the issue you can simply call window.postMessage on a page of puppeteer using page.evaluate

const runtime = await runBrowserWith(path.resolve(__dirname, 'mocks.ts'))

runtime.page.evaluate(() => {
   window.postMessage({
       source: 'external-message',
   });
})
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found