Skip to content

Commit

Permalink
fix(jest-environment-node): Add structuredClone to globals (#12631)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araxeus committed Apr 4, 2022
1 parent b82fd89 commit c7b1538
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -59,7 +59,8 @@
- `[jest-each]` `%#` is not replaced with index of the test case ([#12517](https://github.com/facebook/jest/pull/12517))
- `[jest-environment-jsdom]` Make `jsdom` accessible to extending environments again ([#12232](https://github.com/facebook/jest/pull/12232))
- `[jest-environment-jsdom]` Log JSDOM errors more cleanly ([#12386](https://github.com/facebook/jest/pull/12386))
- `[jest-environment-node]` Add MessageChannel, MessageEvent to globals ([#12553](https://github.com/facebook/jest/pull/12553))
- `[jest-environment-node]` Add `MessageChannel`, `MessageEvent` to globals ([#12553](https://github.com/facebook/jest/pull/12553))
- `[jest-environment-node]` Add `structuredClone` to globals ([#12631](https://github.com/facebook/jest/pull/12631))
- `[@jest/expect-utils]` [**BREAKING**] Fix false positives when looking for `undefined` prop ([#8923](https://github.com/facebook/jest/pull/8923))
- `[jest-haste-map]` Don't use partial results if file crawl errors ([#12420](https://github.com/facebook/jest/pull/12420))
- `[jest-jasmine2, jest-types]` [**BREAKING**] Move all `jasmine` specific types from `@jest/types` to its own package ([#12125](https://github.com/facebook/jest/pull/12125))
Expand Down
6 changes: 6 additions & 0 deletions packages/jest-environment-node/src/index.ts
Expand Up @@ -95,6 +95,12 @@ export default class NodeEnvironment implements JestEnvironment<Timer> {
global.atob = atob;
global.btoa = btoa;
}
// structuredClone is global in Node >= 17
// @ts-expect-error type definition for structuredClone is missing
if (typeof structuredClone !== 'undefined') {
// @ts-expect-error type definition for structuredClone is missing
global.structuredClone = structuredClone;
}
installCommonGlobals(global, projectConfig.globals);

this.moduleMocker = new ModuleMocker(global);
Expand Down

0 comments on commit c7b1538

Please sign in to comment.