Skip to content

Commit 53642ae

Browse files
committed
Adds '--cls' option to clear screen between watch runs
1 parent 024de32 commit 53642ae

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/cli.js

+7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ const FLAGS = {
9191
description: 'Re-run tests when files change',
9292
type: 'boolean',
9393
},
94+
'clear-screen': {
95+
alias: 'C',
96+
coerce: coerceLastValue,
97+
description: 'Clears the screen before every test run',
98+
type: 'boolean',
99+
},
94100
};
95101

96102
export default async function loadCli() { // eslint-disable-line complexity
@@ -465,6 +471,7 @@ export default async function loadCli() { // eslint-disable-line complexity
465471
reportStream: process.stdout,
466472
stdStream: process.stderr,
467473
watching: argv.watch,
474+
clearScreen: argv['clear-screen'],
468475
});
469476
}
470477

lib/reporters/default.js

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'node:path';
33
import stream from 'node:stream';
44
import {fileURLToPath} from 'node:url';
55

6+
import ansiEscapes from 'ansi-escapes';
67
import figures from 'figures';
78
import indentString from 'indent-string';
89
import plur from 'plur';
@@ -73,12 +74,14 @@ export default class Reporter {
7374
stdStream,
7475
projectDir,
7576
watching,
77+
clearScreen,
7678
durationThreshold,
7779
}) {
7880
this.extensions = extensions;
7981
this.reportStream = reportStream;
8082
this.stdStream = stdStream;
8183
this.watching = watching;
84+
this.clearScreen = clearScreen;
8285
this.relativeFile = file => {
8386
if (file.startsWith('file://')) {
8487
file = fileURLToPath(file);
@@ -128,6 +131,10 @@ export default class Reporter {
128131
}
129132

130133
startRun(plan) {
134+
if (this.clearScreen) {
135+
this.lineWriter.write(ansiEscapes.clearTerminal);
136+
}
137+
131138
if (plan.bailWithoutReporting) {
132139
return;
133140
}

0 commit comments

Comments
 (0)