mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

TypeError: Cannot redefine property: Request at Function.defineProperty (<anonymous>) #2286

Closed AdrienFromToulouse closed 2 months ago

AdrienFromToulouse commented 2 months ago

Prerequisites

Environment check

Node.js version

v20

Reproduction repository

https://donthavearepotoshare.com

Reproduction steps

Hi, since 2.4.4 there was this issue https://github.com/mswjs/msw/issues/2276 unfortunately the 2.4.7 version has still some issues it seems. With the error TypeError: Cannot redefine property: Request at Function.defineProperty (<anonymous>) I think linked to: https://github.com/mswjs/msw/pull/2283

Cheers,

Current behavior

TypeError: Cannot redefine property: Request at Function.defineProperty ()

Expected behavior

No error.

kettanaito commented 2 months ago

Hi, @AdrienFromToulouse. Thanks for reporting this. Sadly, I cannot look into issues without a reproduction repo. Whomever encountering this also are highly encouraged to provide one. Thank you for understanding.

rafaelji commented 2 months ago

I'm facing the same problem! Couldn't find a solution 😞

jcrang commented 2 months ago

For us this was an issue with the recommended Jest polyfills.

We've resolved this by changing the recommended Jest polyfills to make Request and Reponse configurable.

PR for the docs change https://github.com/mswjs/mswjs.io/pull/416

AdrienFromToulouse commented 2 months ago

For us this was an issue with the recommended Jest polyfills.

We've resolved this by changing the recommended Jest polyfills to make Request and Reponse configurable.

PR for the docs change mswjs/mswjs.io#416

Many thanks for pointing that out @jcrang works like a charm now 🙏