Skip to content
Open
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
19 changes: 18 additions & 1 deletion lib/internal/test_runner/reporter/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ const {
MathMax,
} = primordials;
const colors = require('internal/util/colors');
const { formatTestReport } = require('internal/test_runner/reporter/utils');
const { formatTestReport, getCoverageReport } = require('internal/test_runner/reporter/utils');

module.exports = async function* dot(source) {
let count = 0;
let columns = getLineLength();
const failedTests = [];
const coverageFailures = [];
for await (const { type, data } of source) {
if (type === 'test:pass') {
yield `${colors.green}.${colors.reset}`;
Expand All @@ -18,6 +19,16 @@ module.exports = async function* dot(source) {
yield `${colors.red}X${colors.reset}`;
ArrayPrototypePush(failedTests, data);
}
if (type === 'test:coverage') {
// Check if coverage failed (threshold not met)
if (data.summary && (
(data.summary.lines && data.summary.lines.pct < 100) ||
(data.summary.functions && data.summary.functions.pct < 100) ||
(data.summary.branches && data.summary.branches.pct < 100)
)) {
ArrayPrototypePush(coverageFailures, data);
}
}
if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) {
yield '\n';

Expand All @@ -33,6 +44,12 @@ module.exports = async function* dot(source) {
yield formatTestReport('test:fail', test);
}
}
if (coverageFailures.length > 0) {
yield `\n${colors.red}Coverage report failed:${colors.white}\n\n`;
for (const coverage of coverageFailures) {
yield getCoverageReport('', coverage.summary, 'ℹ ', colors.blue, true);
}
}
};

function getLineLength() {
Expand Down