Skip to content

Use Node's TextEncoder in E2E JSDOM Environment #8783

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

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions e2e/fix-jsdom-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@
import JSDOMEnvironment from 'jest-environment-jsdom';

/**
* JSDOMEnvironment patch to polyfill missing fetch with native
* Node fetch
* JSDOMEnvironment patch to polyfill missing APIs with Node APIs.
*/
// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string
export default class FixJSDOMEnvironment extends JSDOMEnvironment {
constructor(...args: ConstructorParameters<typeof JSDOMEnvironment>) {
super(...args);

// FIXME https://github.com/jsdom/jsdom/issues/1724
// Fetch
// FIXME: https://github.com/jsdom/jsdom/issues/1724
this.global.fetch = fetch;
this.global.Headers = Headers;
this.global.Request = Request;
this.global.Response = Response;

// Util
this.global.TextEncoder = TextEncoder;
}
}
3 changes: 1 addition & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "",
"main": "index.js",
"scripts": {
"setup": "node test-setup.js",
"test": "yarn jest",
"test:compat": "yarn jest tests/compat.test.ts",
"test:modular": "yarn jest tests/modular.test.ts",
Expand All @@ -18,7 +17,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"firebase": "11.0.2"
"firebase": "11.3.0"
},
"devDependencies": {
"@babel/core": "7.26.0",
Expand Down
Loading
Loading