Skip to content

Commit b425d8d

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

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
@@ -53,6 +53,7 @@
5353
- `[jest-each]` `%#` is not replaced with index of the test case ([#12517](https://github.com/facebook/jest/pull/12517))
5454
- `[jest-environment-jsdom]` Make `jsdom` accessible to extending environments again ([#12232](https://github.com/facebook/jest/pull/12232))
5555
- `[jest-environment-jsdom]` Log JSDOM errors more cleanly ([#12386](https://github.com/facebook/jest/pull/12386))
56+
- `[jest-environment-node]` Add MessageChannel, MessageEvent and MessagePort to globals ([#12553](https://github.com/facebook/jest/pull/12553))
5657
- `[@jest/expect-utils]` [**BREAKING**] Fix false positives when looking for `undefined` prop ([#8923](https://github.com/facebook/jest/pull/8923))
5758
- `[jest-haste-map]` Don't use partial results if file crawl errors ([#12420](https://github.com/facebook/jest/pull/12420))
5859
- `[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))

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)