TypeError: Cannot redefine property: Request at Function.defineProperty (<anonymous>) #2288
Replies: 4 comments 3 replies
-
When I look at Discussed in #2271, I thought the problem might related to version, so I changed it from 2.4.8 to 2.4.7 as described but my problem was still there. So after further research, I saw this comment #2271 (comment) and finally 2.4.3 version solved my problem.
|
Beta Was this translation helpful? Give feedback.
-
the error happens because in your polyfill, you didn't allow Request to be configurable You can adjust it like this Object.defineProperties(globalThis, {
fetch: { value: fetch, writable: true },
Blob: { value: Blob },
File: { value: File },
Headers: { value: Headers },
FormData: { value: FormData },
Request: { value: Request, configurable: true },
Response: { value: Response, configurable: true },
}); |
Beta Was this translation helpful? Give feedback.
-
[IMHO] I refered this document and it's completely worked at [email protected] https://mswjs.io/docs/faq/#requestresponsetextencoder-is-not-defined-jest
|
Beta Was this translation helpful? Give feedback.
-
Please note that the Jest usage instructions have been updated today. You are encouraged to use |
Beta Was this translation helpful? Give feedback.
-
Okay after dealing with TextEncoder and ReadableStream is not defined errors, I finally got chance to test my api but now
I'm getting this error when I run my test on my reservation.test.tsx file.
https://github.com/halilibrahimcelik/jest-test-repo-base-venue this is the project repo btw, you can look at my configurations on msw handlers and servers file as well as jest files.
Any help really appreciated.
Beta Was this translation helpful? Give feedback.
All reactions