Skip to content

Commit 45d4274

Browse files
authored
Use Node's TextEncoder in E2E JSDOM Environment (#8783)
1 parent deb917b commit 45d4274

File tree

3 files changed

+242
-234
lines changed

3 files changed

+242
-234
lines changed

e2e/fix-jsdom-environment.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@
1818
import JSDOMEnvironment from 'jest-environment-jsdom';
1919

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

29-
// FIXME https://github.com/jsdom/jsdom/issues/1724
28+
// Fetch
29+
// FIXME: https://github.com/jsdom/jsdom/issues/1724
3030
this.global.fetch = fetch;
3131
this.global.Headers = Headers;
3232
this.global.Request = Request;
3333
this.global.Response = Response;
34+
35+
// Util
36+
this.global.TextEncoder = TextEncoder;
3437
}
3538
}

e2e/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"setup": "node test-setup.js",
87
"test": "yarn jest",
98
"test:compat": "yarn jest tests/compat.test.ts",
109
"test:modular": "yarn jest tests/modular.test.ts",
@@ -18,7 +17,7 @@
1817
"author": "",
1918
"license": "ISC",
2019
"dependencies": {
21-
"firebase": "11.0.2"
20+
"firebase": "11.3.0"
2221
},
2322
"devDependencies": {
2423
"@babel/core": "7.26.0",

0 commit comments

Comments
 (0)