Skip to content

Commit a2d76a3

Browse files
committed
fix(reporter): don't print all dots in one line
CI systems like GitHub Actions only print a line when a newline character is printed. Add a newline character after each 100 dots to flush output mid-test. Fixes gh-30
1 parent 7d4fa44 commit a2d76a3

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

reporter.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import chalk from "chalk";
22
import { prettyMs } from "./lib/prettyMs.js";
33
import * as Diff from "diff";
44

5+
const MAX_DOTS_PER_LINE = 100;
6+
57
function serializeForDiff( value ) {
68

79
// Use naive serialization for everything except types with confusable values
@@ -14,11 +16,23 @@ function serializeForDiff( value ) {
1416
return `${ value }`;
1517
}
1618

19+
let currDots = 0;
20+
function writeDot() {
21+
if ( currDots >= MAX_DOTS_PER_LINE ) {
22+
23+
// Write a newline character occasionally to force a CI output flush.
24+
process.stdout.write( "\n" );
25+
currDots = 0;
26+
}
27+
currDots++;
28+
process.stdout.write( "." );
29+
}
30+
1731
export function reportTest( test, { fullBrowser, id } ) {
1832
if ( test.status === "passed" ) {
1933

20-
// Write to console without newlines
21-
process.stdout.write( "." );
34+
// Write to console
35+
writeDot();
2236
return;
2337
}
2438

0 commit comments

Comments
 (0)