diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f90b8d5235..8e0c1601074b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - `[jest-environment-node]` [**BREAKING**] Add default `node` and `node-addon` conditions to `exportConditions` for `node` environment ([#11924](https://github.com/facebook/jest/pull/11924)) - `[jest-environment-node]` [**BREAKING**] Pass global config to Jest environment constructor for `node` environment ([#12461](https://github.com/facebook/jest/pull/12461)) - `[jest-environment-node]` [**BREAKING**] Second argument `context` to constructor is mandatory ([#12469](https://github.com/facebook/jest/pull/12469)) +- `[jest-environment-node]` Add MessageChannel, MessageEvent and MessagePort to globals ([#](https://github.com/facebook/jest/pull/)) - `[@jest/expect]` New module which extends `expect` with `jest-snapshot` matchers ([#12404](https://github.com/facebook/jest/pull/12404), [#12410](https://github.com/facebook/jest/pull/12410), [#12418](https://github.com/facebook/jest/pull/12418)) - `[@jest/expect-utils]` New module exporting utils for `expect` ([#12323](https://github.com/facebook/jest/pull/12323)) - `[jest-haste-map]` [**BREAKING**] `HasteMap.create` now returns a promise ([#12008](https://github.com/facebook/jest/pull/12008)) diff --git a/packages/jest-environment-node/src/index.ts b/packages/jest-environment-node/src/index.ts index e49d7b162c00..a15f11b208e7 100644 --- a/packages/jest-environment-node/src/index.ts +++ b/packages/jest-environment-node/src/index.ts @@ -78,6 +78,18 @@ export default class NodeEnvironment implements JestEnvironment { if (typeof EventTarget !== 'undefined') { global.EventTarget = EventTarget; } + // MessageChannel is global in Node >= 15 + if (typeof MessageChannel !== 'undefined') { + global.MessageChannel = MessageChannel; + } + // MessageEvent is global in Node >= 15 + if (typeof MessageEvent !== 'undefined') { + global.MessageEvent = MessageEvent; + } + // MessagePort is global in Node >= 15 + if (typeof MessagePort !== 'undefined') { + global.MessagePort = MessagePort; + } // performance is global in Node >= 16 if (typeof performance !== 'undefined') { global.performance = performance;