Skip to content
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

Update jest-missing-globals.mdx #353

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/content/docs/shared/jest-missing-globals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ Create a `jest.polyfills.js` file next to your `jest.config.js` with the followi
* you don't want to deal with this.
*/

const { TextDecoder, TextEncoder } = require('node:util')
const { TextDecoder, TextEncoder, ReadableStream } = require("node:util")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep quotes as they are

Suggested change
const { TextDecoder, TextEncoder, ReadableStream } = require("node:util")
const { TextDecoder, TextEncoder, ReadableStream } = require('node:util')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect though. Must be imported from node:stream/web. That's the correct implementation of web's ReadableStream. We've already had issues with people trying to polyfill the stream from node:utils and it fails.


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')
const { Blob, File } = require("node:buffer")
const { fetch, Headers, FormData, Request, Response } = require("undici")
Comment on lines +35 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { Blob, File } = require("node:buffer")
const { fetch, Headers, FormData, Request, Response } = require("undici")
const { Blob, File } = require('node:buffer')
const { fetch, Headers, FormData, Request, Response } = require('undici')


Object.defineProperties(globalThis, {
fetch: { value: fetch, writable: true },
Expand Down