Skip to content

Commit

Permalink
fix(jest-environment-node): Add Event and EventTarget to node global (j…
Browse files Browse the repository at this point in the history
  • Loading branch information
jayphelps authored and splincode committed Aug 24, 2021
1 parent 9f59860 commit b65a1d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- `[jest-types]` Compat with `@types/node` v16 ([#11645](https://github.com/facebook/jest/pull/11645))
- `[jest-environment-node]` Add `Event` and `EventTarget` to node global environment. ([#11705](https://github.com/facebook/jest/issues/11705))

### Chore & Maintenance

Expand Down
8 changes: 8 additions & 0 deletions packages/jest-environment-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class NodeEnvironment implements JestEnvironment {
if (typeof AbortController !== 'undefined') {
global.AbortController = AbortController;
}
// Event is global in Node >= 15.4
if (typeof Event !== 'undefined') {
global.Event = Event;
}
// EventTarget is global in Node >= 15.4
if (typeof EventTarget !== 'undefined') {
global.EventTarget = EventTarget;
}
installCommonGlobals(global, config.globals);

this.moduleMocker = new ModuleMocker(global);
Expand Down

0 comments on commit b65a1d8

Please sign in to comment.