mswjs / interceptors

Low-level network interception library.
https://npm.im/@mswjs/interceptors
MIT License
563 stars 127 forks source link

`globalThis.WebSocket` is undefined and it can't be proxied. #668

Open Afsoon opened 1 day ago

Afsoon commented 1 day ago

Hello

Our current dependanbot PR is failing with the latest MSW version, after debugging and tracking changes in the repository I have conclude the following:

Our setup is Vitest + Happy-DOM + Remix, I have tested prior version of MSW, and it didn't have this problem.

I'm not 100% sure of the fix, but I think it's a missing a check that is:

  if (typeof descriptor.get() === "undefined") {
    return false;
  }

If it's the fix, I can create a PR with the test.

kettanaito commented 16 hours ago

Hi, @Afsoon. Thanks for reporting this.

Let's discuss it first. Just checking the getter not being there isn't enough—the property descriptor can have a value and no get, and that's a valid property that must return true. Will look at your pull request in more detail once I have a moment (thanks for opening that btw!).