Skip to content

Commit

Permalink
test_runner: added colors to dot reporter
Browse files Browse the repository at this point in the history
PR-URL: nodejs#53450
Fixes: nodejs#51770
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Giovanni authored and MoLow committed Jul 23, 2024
1 parent e192a32 commit 8536b67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/internal/test_runner/reporter/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ module.exports = async function* dot(source) {
const failedTests = [];
for await (const { type, data } of source) {
if (type === 'test:pass') {
yield '.';
yield `${colors.green}.${colors.clear}`;
}
if (type === 'test:fail') {
yield 'X';
yield `${colors.red}X${colors.clear}`;
ArrayPrototypePush(failedTests, data);
}
if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) {
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/test-runner/output/dot_output_custom_columns.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Flags: --test-reporter=dot
'use strict';
process.stdout.columns = 30;
process.env.FORCE_COLOR = '1';
delete process.env.NODE_DISABLE_COLORS;
delete process.env.NO_COLOR;

const test = require('node:test');
const { setTimeout } = require('timers/promises');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
..............................
.........................................
.............................
[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c
[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c
[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c[32m.c

0 comments on commit 8536b67

Please sign in to comment.