Skip to content

Commit

Permalink
Add MessageChannel, MessageEvent and MessagePort to globals
Browse files Browse the repository at this point in the history
  • Loading branch information
F3n67u committed Mar 6, 2022
1 parent 871a8e7 commit b425d8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- `[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 and MessagePort to globals ([#12553](https://github.com/facebook/jest/pull/12553))
- `[@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
12 changes: 12 additions & 0 deletions packages/jest-environment-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ export default class NodeEnvironment implements JestEnvironment<Timer> {
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;
Expand Down

0 comments on commit b425d8d

Please sign in to comment.