Skip to content

Commit 45db682

Browse files
committed
move to coverage.js
1 parent f86abda commit 45db682

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/internal/test_runner/coverage.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ class CoverageLine {
5050
}
5151

5252
class TestCoverage {
53-
constructor(coverageDirectory, originalCoverageDirectory, workingDirectory, excludeGlobs, includeGlobs) {
53+
constructor(coverageDirectory, originalCoverageDirectory, workingDirectory, excludeGlobs, includeGlobs, thresholds) {
5454
this.coverageDirectory = coverageDirectory;
5555
this.originalCoverageDirectory = originalCoverageDirectory;
5656
this.workingDirectory = workingDirectory;
5757
this.excludeGlobs = excludeGlobs;
5858
this.includeGlobs = includeGlobs;
59+
this.thresholds = thresholds;
5960
}
6061

6162
#sourceLines = new SafeMap();
@@ -142,6 +143,7 @@ class TestCoverage {
142143
coveredBranchPercent: 0,
143144
coveredFunctionPercent: 0,
144145
},
146+
thresholds: this.thresholds,
145147
};
146148

147149
if (!coverage) {
@@ -497,6 +499,12 @@ function setupCoverage(options) {
497499
cwd,
498500
options.coverageExcludeGlobs,
499501
options.coverageIncludeGlobs,
502+
{
503+
__proto__: null,
504+
line: options.lineCoverage,
505+
branch: options.branchCoverage,
506+
function: options.functionCoverage,
507+
},
500508
);
501509
}
502510

lib/internal/test_runner/test.js

-2
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,8 @@ class Test extends AsyncResource {
10211021
threshold: this.config.functionCoverage, name: 'function' },
10221022
];
10231023

1024-
coverage.thresholds = { __proto__: null };
10251024
for (let i = 0; i < coverages.length; i++) {
10261025
const { threshold, actual, name } = coverages[i];
1027-
coverage.thresholds[name] = threshold;
10281026
if (actual < threshold) {
10291027
process.exitCode = kGenericUserError;
10301028
reporter.diagnostic(nesting, loc, `Error: ${NumberPrototypeToFixed(actual, 2)}% ${name} coverage does not meet threshold of ${threshold}%.`);

0 commit comments

Comments
 (0)