From a8e5994417d24ccc30731d51026c814a3ce23a9d Mon Sep 17 00:00:00 2001 From: Mitchell Hentges Date: Mon, 19 Sep 2022 17:56:22 +0200 Subject: [PATCH 1/2] Don't perform V8 instrumenting if !collectCoverage If `coverageProvider: "v8"` is provided in the Jest config, then the overhead of V8 instrumenting occurs, even if `collectCoverage: false`. This saves about ~100ms of Jest-invocation-time on my machine. Signed-off-by: Mitchell Hentges --- packages/jest-runner/src/runTest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/jest-runner/src/runTest.ts b/packages/jest-runner/src/runTest.ts index 40b69f771207..1fcb193430c8 100644 --- a/packages/jest-runner/src/runTest.ts +++ b/packages/jest-runner/src/runTest.ts @@ -270,6 +270,7 @@ async function runTestInternal( // if we don't have `getVmContext` on the env skip coverage const collectV8Coverage = + globalConfig.collectCoverage && globalConfig.coverageProvider === 'v8' && typeof environment.getVmContext === 'function'; From 60e10d6ab91cb29c3762f231889611a767507f9d Mon Sep 17 00:00:00 2001 From: Mitchell Hentges Date: Wed, 28 Sep 2022 11:16:14 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md Signed-off-by: Mitchell Hentges --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8a4d33ec1c1..86e0903a1e28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixes - `[babel-plugin-jest-hoist]` Ignore `TSTypeQuery` when checking for hoisted references ([#13367](https://github.com/facebook/jest/pull/13367)) +- `[jest-runner]` Do not instrument v8 coverage data if coverage should not be collected [#13282](https://github.com/facebook/jest/pull/13282) ### Chore & Maintenance