diff --git a/lib/cli.js b/lib/cli.js index dd0c9feb2..d744e457a 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -91,6 +91,12 @@ const FLAGS = { description: 'Re-run tests when files change', type: 'boolean', }, + cls: { + alias: 'C', + coerce: coerceLastValue, + description: 'Clears the screen between test runs', + type: 'boolean', + }, }; export default async function loadCli() { // eslint-disable-line complexity @@ -465,6 +471,7 @@ export default async function loadCli() { // eslint-disable-line complexity reportStream: process.stdout, stdStream: process.stderr, watching: argv.watch, + cls: argv.cls, }); } diff --git a/lib/reporters/default.js b/lib/reporters/default.js index a70f24e4e..fe6309742 100644 --- a/lib/reporters/default.js +++ b/lib/reporters/default.js @@ -73,12 +73,14 @@ export default class Reporter { stdStream, projectDir, watching, + cls, durationThreshold, }) { this.extensions = extensions; this.reportStream = reportStream; this.stdStream = stdStream; this.watching = watching; + this.cls = cls; this.relativeFile = file => { if (file.startsWith('file://')) { file = fileURLToPath(file); @@ -128,6 +130,10 @@ export default class Reporter { } startRun(plan) { + if (this.cls) { + process.stderr.write('\x1b[2J\x1b[H\x1b[3J'); + } + if (plan.bailWithoutReporting) { return; }