From 8472cf03ce4c2f6e269a6ff5ae635a07e1eb695e Mon Sep 17 00:00:00 2001 From: Simon Siefke Date: Wed, 27 Oct 2021 18:06:14 +0200 Subject: [PATCH 1/4] add performance global to nodejs environment --- packages/jest-environment-node/src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/jest-environment-node/src/index.ts b/packages/jest-environment-node/src/index.ts index 2f3a433ac391..78cfcb669f82 100644 --- a/packages/jest-environment-node/src/index.ts +++ b/packages/jest-environment-node/src/index.ts @@ -72,7 +72,11 @@ class NodeEnvironment implements JestEnvironment { } // EventTarget is global in Node >= 15.4 if (typeof EventTarget !== 'undefined') { - global.EventTarget = EventTarget; + global.EventTarget = EventTarget;`` + } + // performance is global in Node >= 16 + if(typeof performance !=='undefined'){ + global.performance = performance } installCommonGlobals(global, config.globals); From 891aac4d6a64757d3d06ce382bd74d1422ebaaa2 Mon Sep 17 00:00:00 2001 From: Simon Siefke Date: Wed, 27 Oct 2021 18:12:39 +0200 Subject: [PATCH 2/4] remove unused code --- packages/jest-environment-node/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-environment-node/src/index.ts b/packages/jest-environment-node/src/index.ts index 78cfcb669f82..27a39e2a207a 100644 --- a/packages/jest-environment-node/src/index.ts +++ b/packages/jest-environment-node/src/index.ts @@ -72,7 +72,7 @@ class NodeEnvironment implements JestEnvironment { } // EventTarget is global in Node >= 15.4 if (typeof EventTarget !== 'undefined') { - global.EventTarget = EventTarget;`` + global.EventTarget = EventTarget; } // performance is global in Node >= 16 if(typeof performance !=='undefined'){ From c1492d7ca7ff4e0a5641a5b48bba61142e9c71fa Mon Sep 17 00:00:00 2001 From: Simon Siefke Date: Wed, 27 Oct 2021 18:13:32 +0200 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7cd6accaa41..b453b91e0745 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - `[expect]` Allow again `expect.Matchers` generic with single value ([#11986](https://github.com/facebook/jest/pull/11986)) - `[jest-environment-jsdom]` Add `@types/jsdom` dependency ([#11999](https://github.com/facebook/jest/pull/11999)) +- `[jest-environment-node]` Add Missing node global `performance` ([#12002](https://github.com/facebook/jest/pull/12002)) ### Chore & Maintenance From eaf37fc5d5f2d3e10ad3dcfb4ca7927040052e5e Mon Sep 17 00:00:00 2001 From: Simon Siefke Date: Sat, 30 Oct 2021 09:07:24 +0200 Subject: [PATCH 4/4] fix formatting --- packages/jest-environment-node/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-environment-node/src/index.ts b/packages/jest-environment-node/src/index.ts index 27a39e2a207a..94452cb8c262 100644 --- a/packages/jest-environment-node/src/index.ts +++ b/packages/jest-environment-node/src/index.ts @@ -75,8 +75,8 @@ class NodeEnvironment implements JestEnvironment { global.EventTarget = EventTarget; } // performance is global in Node >= 16 - if(typeof performance !=='undefined'){ - global.performance = performance + if (typeof performance !== 'undefined') { + global.performance = performance; } installCommonGlobals(global, config.globals);