Skip to content

Commit

Permalink
add global in jsdom as well
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 18, 2020
1 parent 5fd9549 commit 830ff89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -7,7 +7,7 @@
### Fixes

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

### Chore & Maintenance
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-environment-jsdom/src/index.ts
Expand Up @@ -45,6 +45,9 @@ class JSDOMEnvironment implements JestEnvironment {
throw new Error('JSDOM did not return a Window object');
}

// for "universal" code (code should use `globalThis`)
global.global = global;

// In the `jsdom@16`, ArrayBuffer was not added to Window, ref: https://github.com/jsdom/jsdom/commit/3a4fd6258e6b13e9cf8341ddba60a06b9b5c7b5b
// Install ArrayBuffer to Window to fix it. Make sure the test is passed, ref: https://github.com/facebook/jest/pull/7626
global.ArrayBuffer = ArrayBuffer;
Expand Down

0 comments on commit 830ff89

Please sign in to comment.