From 15336c31397dcbe557c416972676c03599bd86b7 Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Mon, 29 May 2023 00:47:21 -0400 Subject: [PATCH] test_runner: remove redundant check from coverage The code coverage reporting logic already filters out URLs that don't start with 'file:', so there is no need to also filter out URLs that start with 'node:'. PR-URL: https://github.com/nodejs/node/pull/48070 Reviewed-By: Antoine du Hamel Reviewed-By: Moshe Atlow Reviewed-By: Debadree Chatterjee --- lib/internal/test_runner/coverage.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/internal/test_runner/coverage.js b/lib/internal/test_runner/coverage.js index 5a098f71af633b..a20055fa91b601 100644 --- a/lib/internal/test_runner/coverage.js +++ b/lib/internal/test_runner/coverage.js @@ -377,10 +377,13 @@ function mergeCoverage(merged, coverage) { const newScript = coverage[i]; const { url } = newScript; - // Filter out core modules and the node_modules/ directory from results. - if (StringPrototypeStartsWith(url, 'node:') || - StringPrototypeIncludes(url, '/node_modules/') || - // On Windows some generated coverages are invalid. + // The first part of this check filters out the node_modules/ directory + // from the results. This filter is applied first because most real world + // applications will be dominated by third party dependencies. The second + // part of the check filters out core modules, which start with 'node:' in + // coverage reports, as well as any invalid coverages which have been + // observed on Windows. + if (StringPrototypeIncludes(url, '/node_modules/') || !StringPrototypeStartsWith(url, 'file:')) { continue; }