Skip to content

Commit 830ff89

Browse files
committed
add global in jsdom as well
1 parent 5fd9549 commit 830ff89

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
### Fixes
88

99
- `[jest-runtime]` `require.main` is no longer `undefined` when using `jest.resetModules` ([#10626](https://github.com/facebook/jest/pull/10626))
10-
- `[jest-runtime]` Do not inject `global` variable into module wrapper ([#10644](https://github.com/facebook/jest/pull/10644))
10+
- `[jest-runtime]` [**BREAKING**] Do not inject `global` variable into module wrapper ([#10644](https://github.com/facebook/jest/pull/10644))
1111
- `[@jest/types]` Add missing values for `timers` ([#10632](https://github.com/facebook/jest/pull/10632))
1212

1313
### Chore & Maintenance

packages/jest-environment-jsdom/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class JSDOMEnvironment implements JestEnvironment {
4545
throw new Error('JSDOM did not return a Window object');
4646
}
4747

48+
// for "universal" code (code should use `globalThis`)
49+
global.global = global;
50+
4851
// In the `jsdom@16`, ArrayBuffer was not added to Window, ref: https://github.com/jsdom/jsdom/commit/3a4fd6258e6b13e9cf8341ddba60a06b9b5c7b5b
4952
// Install ArrayBuffer to Window to fix it. Make sure the test is passed, ref: https://github.com/facebook/jest/pull/7626
5053
global.ArrayBuffer = ArrayBuffer;

0 commit comments

Comments
 (0)