Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/internal/test_runner/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ class TestCoverage {
ArrayPrototypePush(branchReports, {
__proto__: null,
line: range.lines[0]?.line,
count: range.count,
count: range.count !== 0 ? range.count :
range.ignoredLines > 0 ? 1 : 0,
});

if (range.count !== 0 ||
range.ignoredLines === range.lines.length) {
if (range.count !== 0 || range.ignoredLines > 0) {
branchesCovered++;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/internal/test_runner/reporter/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
MathMax,
} = primordials;
const colors = require('internal/util/colors');
const { getCoverageReport } = require('internal/test_runner/utils');
const { formatTestReport } = require('internal/test_runner/reporter/utils');

module.exports = async function* dot(source) {
Expand All @@ -18,6 +19,9 @@ module.exports = async function* dot(source) {
yield `${colors.red}X${colors.reset}`;
ArrayPrototypePush(failedTests, data);
}
if (type === 'test:coverage') {
yield getCoverageReport('', data.summary, '', '', true);
}
if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) {
yield '\n';

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-runner-coverage-thresholds.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ function getTapCoverageFixtureReport() {
'# test | | | | ',
'# fixtures | | | | ',
'# test-runner | | | | ',
'# coverage.js | 78.65 | 38.46 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# coverage.js | 78.65 | 46.15 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# invalid-tap.js | 100.00 | 100.00 | 100.00 | ',
'# v8-coverage | | | | ',
'# throw.js | 71.43 | 50.00 | 100.00 | 5-6',
'# --------------------------------------------------------------------------------------------',
'# all files | 78.35 | 43.75 | 60.00 | ',
'# all files | 78.35 | 50.00 | 60.00 | ',
'# --------------------------------------------------------------------------------------------',
'# end of coverage report',
].join('\n');
Expand All @@ -53,7 +53,7 @@ const reporter = fixtures.fileURL('test-runner/custom_reporters/coverage.mjs');
const coverages = [
{ flag: '--test-coverage-lines', name: 'line', actual: 78.35 },
{ flag: '--test-coverage-functions', name: 'function', actual: 60.00 },
{ flag: '--test-coverage-branches', name: 'branch', actual: 43.75 },
{ flag: '--test-coverage-branches', name: 'branch', actual: 50.00 },
];

for (const coverage of coverages) {
Expand Down
26 changes: 13 additions & 13 deletions test/parallel/test-runner-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ function getTapCoverageFixtureReport() {
'# test | | | | ',
'# fixtures | | | | ',
'# test-runner | | | | ',
'# coverage.js | 78.65 | 38.46 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# coverage.js | 78.65 | 46.15 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# invalid-tap.js | 100.00 | 100.00 | 100.00 | ',
'# v8-coverage | | | | ',
'# throw.js | 71.43 | 50.00 | 100.00 | 5-6',
'# --------------------------------------------------------------------------------------------',
'# all files | 78.35 | 43.75 | 60.00 | ',
'# all files | 78.35 | 50.00 | 60.00 | ',
'# --------------------------------------------------------------------------------------------',
'# end of coverage report',
].join('\n');
Expand All @@ -59,12 +59,12 @@ function getSpecCoverageFixtureReport() {
'\u2139 test | | | | ',
'\u2139 fixtures | | | | ',
'\u2139 test-runner | | | | ',
'\u2139 coverage.js | 78.65 | 38.46 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'\u2139 coverage.js | 78.65 | 46.15 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'\u2139 invalid-tap.js | 100.00 | 100.00 | 100.00 | ',
'\u2139 v8-coverage | | | | ',
'\u2139 throw.js | 71.43 | 50.00 | 100.00 | 5-6',
'\u2139 --------------------------------------------------------------------------------------------',
'\u2139 all files | 78.35 | 43.75 | 60.00 | ',
'\u2139 all files | 78.35 | 50.00 | 60.00 | ',
'\u2139 --------------------------------------------------------------------------------------------',
'\u2139 end of coverage report',
].join('\n');
Expand Down Expand Up @@ -309,7 +309,7 @@ test('coverage reports on lines, functions, and branches', skipIfNoInspector, as

await t.test('reports on branch coverage', () => {
const uncalledBranch = file.branches.find((b) => b.line === 6);
assert.strictEqual(uncalledBranch.count, 0);
assert.strictEqual(uncalledBranch.count, 1);

const calledTwice = file.branches.find((b) => b.line === 35);
assert.strictEqual(calledTwice.count, 2);
Expand Down Expand Up @@ -421,11 +421,11 @@ test('coverage with excluded files', skipIfNoInspector, () => {
'# test | | | | ',
'# fixtures | | | | ',
'# test-runner | | | | ',
'# coverage.js | 78.65 | 38.46 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# coverage.js | 78.65 | 46.15 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# v8-coverage | | | | ',
'# throw.js | 71.43 | 50.00 | 100.00 | 5-6',
'# -----------------------------------------------------------------------------------------',
'# all files | 78.13 | 40.00 | 60.00 | ',
'# all files | 78.13 | 46.67 | 60.00 | ',
'# -----------------------------------------------------------------------------------------',
'# end of coverage report',
].join('\n');
Expand Down Expand Up @@ -458,11 +458,11 @@ test('coverage with included files', skipIfNoInspector, () => {
'# test | | | | ',
'# fixtures | | | | ',
'# test-runner | | | | ',
'# coverage.js | 78.65 | 38.46 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# coverage.js | 78.65 | 46.15 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# v8-coverage | | | | ',
'# throw.js | 71.43 | 50.00 | 100.00 | 5-6',
'# -----------------------------------------------------------------------------------------',
'# all files | 78.13 | 40.00 | 60.00 | ',
'# all files | 78.13 | 46.67 | 60.00 | ',
'# -----------------------------------------------------------------------------------------',
'# end of coverage report',
].join('\n');
Expand Down Expand Up @@ -494,9 +494,9 @@ test('coverage with included and excluded files', skipIfNoInspector, () => {
'# test | | | | ',
'# fixtures | | | | ',
'# test-runner | | | | ',
'# coverage.js | 78.65 | 38.46 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# coverage.js | 78.65 | 46.15 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# -----------------------------------------------------------------------------------------',
'# all files | 78.65 | 38.46 | 60.00 | ',
'# all files | 78.65 | 46.15 | 60.00 | ',
'# -----------------------------------------------------------------------------------------',
'# end of coverage report',
].join('\n');
Expand All @@ -518,13 +518,13 @@ test('correctly prints the coverage report of files contained in parent director
'# file | line % | branch % | funcs % | uncovered lines',
'# --------------------------------------------------------------------------------------------',
'# .. | | | | ',
'# coverage.js | 78.65 | 38.46 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# coverage.js | 78.65 | 46.15 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',
'# invalid-tap.js | 100.00 | 100.00 | 100.00 | ',
'# .. | | | | ',
'# v8-coverage | | | | ',
'# throw.js | 71.43 | 50.00 | 100.00 | 5-6',
'# --------------------------------------------------------------------------------------------',
'# all files | 78.35 | 43.75 | 60.00 | ',
'# all files | 78.35 | 50.00 | 60.00 | ',
'# --------------------------------------------------------------------------------------------',
'# end of coverage report',
].join('\n');
Expand Down
Loading