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
…environment

Fixes jestjs#11705
  • Loading branch information
jayphelps committed Aug 3, 2021
1 parent fdc74af commit 3504f6b
Showing 1 changed file with 8 additions and 0 deletions.
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 3504f6b

Please sign in to comment.