Skip to content

Commit 967d140

Browse files
committed
Add MessageChannel, MessageEvent and MessagePort to globals
1 parent 871a8e7 commit 967d140

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- `[jest-environment-node]` [**BREAKING**] Add default `node` and `node-addon` conditions to `exportConditions` for `node` environment ([#11924](https://github.com/facebook/jest/pull/11924))
2121
- `[jest-environment-node]` [**BREAKING**] Pass global config to Jest environment constructor for `node` environment ([#12461](https://github.com/facebook/jest/pull/12461))
2222
- `[jest-environment-node]` [**BREAKING**] Second argument `context` to constructor is mandatory ([#12469](https://github.com/facebook/jest/pull/12469))
23+
- `[jest-environment-node]` Add MessageChannel, MessageEvent and MessagePort to globals ([#](https://github.com/facebook/jest/pull/))
2324
- `[@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))
2425
- `[@jest/expect-utils]` New module exporting utils for `expect` ([#12323](https://github.com/facebook/jest/pull/12323))
2526
- `[jest-haste-map]` [**BREAKING**] `HasteMap.create` now returns a promise ([#12008](https://github.com/facebook/jest/pull/12008))

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ export default class NodeEnvironment implements JestEnvironment<Timer> {
7878
if (typeof EventTarget !== 'undefined') {
7979
global.EventTarget = EventTarget;
8080
}
81+
// MessageChannel is global in Node >= 15
82+
if (typeof MessageChannel !== 'undefined') {
83+
global.MessageChannel = MessageChannel;
84+
}
85+
// MessageEvent is global in Node >= 15
86+
if (typeof MessageEvent !== 'undefined') {
87+
global.MessageEvent = MessageEvent;
88+
}
89+
// MessagePort is global in Node >= 15
90+
if (typeof MessagePort !== 'undefined') {
91+
global.MessagePort = MessagePort;
92+
}
8193
// performance is global in Node >= 16
8294
if (typeof performance !== 'undefined') {
8395
global.performance = performance;

0 commit comments

Comments
 (0)