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 967d140
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 @@ -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))
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 967d140

Please sign in to comment.