New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Right-hand side of 'instanceof' is not an object #2082
Comments
Fixed by #2082 |
It was partially solved but still happening for a few tests. |
I was getting a very similar error and was able to solve it, I hope this helps. Make sure you add all the polyfills needed as mentioned here: https://mswjs.io/docs/migrations/1.x-to-2.x#requestresponsetextencoder-is-not-defined-jest. I did the same but I started getting const { TextDecoder, TextEncoder } = require("node:util");
const { ReadableStream } = require("node:stream/web");
Object.defineProperties(globalThis, {
TextDecoder: { value: TextDecoder },
TextEncoder: { value: TextEncoder },
ReadableStream: { value: ReadableStream },
});
const { Blob, File } = require("node:buffer");
const { fetch, Headers, FormData, Request, Response } = require("undici");
Object.defineProperties(globalThis, {
fetch: { value: fetch, writable: true },
Blob: { value: Blob },
File: { value: File },
Headers: { value: Headers },
FormData: { value: FormData },
Request: { value: Request },
Response: { value: Response },
}); |
This worked!!! Thanks A LOT @dsanch3z |
worked for me too thanks @dsanch3z |
I confirm, it works! Thanks a lot @dsanch3z |
I needed also to import
|
Prerequisites
Environment check
msw
versionNode.js version
v18.19.1
Reproduction repository
https://github.com/coder/coder/tree/bq/upgrade-msw
Reproduction steps
pnpm test:ci
Current behavior
When running tests I'm getting the following error:
Expected behavior
Not get the error.
The text was updated successfully, but these errors were encountered: