diff --git a/lib/internal/test_runner/coverage.js b/lib/internal/test_runner/coverage.js index 00452377f85..80dd54d12f3 100644 --- a/lib/internal/test_runner/coverage.js +++ b/lib/internal/test_runner/coverage.js @@ -86,6 +86,7 @@ class TestCoverage { #sourceLines = new SafeMap(); #typeScriptLines = new SafeSet(); + #skipCache = new SafeMap(); getLines(fileUrl, source) { // Split the file source into lines. Make sure the lines maintain their @@ -535,6 +536,14 @@ class TestCoverage { } shouldSkipFileCoverage(url) { + const cached = this.#skipCache.get(url); + if (cached !== undefined) return cached; + const result = this.#computeShouldSkipFileCoverage(url); + this.#skipCache.set(url, result); + return result; + } + + #computeShouldSkipFileCoverage(url) { // This check filters out core modules, which start with 'node:' in // coverage reports, as well as any invalid coverages which have been // observed on Windows.