Skip to content

Commit fda24e5

Browse files
authored
fix(reporter): don't print all dots in one line (#31)
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. Also, fix the lockfile (without it, CI doesn't pass). Fixes gh-30
1 parent 7d4fa44 commit fda24e5

File tree

2 files changed

+23
-37
lines changed

2 files changed

+23
-37
lines changed

package-lock.json

Lines changed: 3 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

reporter.js

Lines changed: 20 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

@@ -114,6 +128,8 @@ export function reportTest( test, { fullBrowser, id } ) {
114128
}
115129

116130
export function reportError( error ) {
131+
currDots = 0;
132+
117133
const title = `${ error.name || "Error" }: ${ error.message }`;
118134
let message = chalk.red( title );
119135

@@ -125,6 +141,8 @@ export function reportError( error ) {
125141
}
126142

127143
export function reportEnd( result, { descriptiveUrl, fullBrowser, id } ) {
144+
currDots = 0;
145+
128146
console.log(
129147
`\n\nTests finished in ${ prettyMs( result.runtime ) } ` +
130148
`at ${ chalk.yellow( descriptiveUrl ) } ` +

0 commit comments

Comments
 (0)