Skip to content

Commit

Permalink
fix(jest-environment-node): Add Event and EventTarget to node global (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jayphelps authored Aug 13, 2021
1 parent 315784d commit 9792b80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Fixes

- `[jest-environment-node]` Add `Event` and `EventTarget` to node global environment. ([#11705](https://github.com/facebook/jest/issues/11705))

### Chore & Maintenance

### Performance
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 9792b80

Please sign in to comment.