Skip to content
Closed
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
11 changes: 10 additions & 1 deletion lib/internal/test_runner/reporter/dot.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
'use strict';
const { MathMax } = primordials;

module.exports = async function* dot(source) {
let count = 0;
let columns = getLineLength();
for await (const { type } of source) {
if (type === 'test:pass') {
yield '.';
}
if (type === 'test:fail') {
yield 'X';
}
if ((type === 'test:fail' || type === 'test:pass') && ++count % 20 === 0) {
if ((type === 'test:fail' || type === 'test:pass') && ++count % columns === 0) {
yield '\n';

// Getting again in case the terminal was resized.
columns = getLineLength();
}
}
yield '\n';
};

function getLineLength() {
return MathMax(process.stdout.columns ?? 20, 20);
}
10 changes: 10 additions & 0 deletions test/fixtures/test-runner/output/dot_output_custom_columns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Flags: --test-reporter=dot
'use strict';
process.stdout.columns = 30;

require('../../../common');
const test = require('node:test');

for (let i = 0; i < 100; i++) {
test(i + ' example', () => {});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
..............................
..............................
..............................
..........
1 change: 1 addition & 0 deletions test/parallel/test-runner-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const tests = [
{ name: 'test-runner/output/unresolved_promise.js' },
{ name: 'test-runner/output/default_output.js', transform: specTransform, tty: true },
{ name: 'test-runner/output/arbitrary-output.js' },
{ name: 'test-runner/output/dot_output_custom_columns.js', transform: specTransform, tty: true },
].map(({ name, tty, transform }) => ({
name,
fn: common.mustCall(async () => {
Expand Down