Skip to content

Commit 32d35c9

Browse files
author
Thomas
committed
Print out warning in verbose and mini reporter when --fail-fast is enabled
1 parent 314f7a0 commit 32d35c9

File tree

7 files changed

+51
-2
lines changed

7 files changed

+51
-2
lines changed

api.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ Api.prototype._run = function (files, options) {
145145
var runStatus = new RunStatus({
146146
runOnlyExclusive: options.runOnlyExclusive,
147147
prefixTitles: this.options.explicitTitles || files.length > 1,
148-
base: path.relative('.', commonPathPrefix(files)) + path.sep
148+
base: path.relative('.', commonPathPrefix(files)) + path.sep,
149+
failFast: this.options.failFast
149150
});
150151

151152
this.emit('test-run', runStatus, files);

lib/colors.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ module.exports = {
99
pass: chalk.green,
1010
duration: chalk.gray.dim,
1111
errorStack: chalk.gray,
12-
stack: chalk.red
12+
stack: chalk.red,
13+
failFast: chalk.magenta
1314
};

lib/reporters/mini.js

+4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ MiniReporter.prototype.finish = function (runStatus) {
216216
});
217217
}
218218

219+
if (runStatus.failFastEnabled === true) {
220+
status += '\n\n ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped');
221+
}
222+
219223
return status + '\n\n';
220224
};
221225

lib/reporters/verbose.js

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ VerboseReporter.prototype.finish = function (runStatus) {
114114
});
115115
}
116116

117+
if (runStatus.failFastEnabled === true) {
118+
output += '\n\n\n ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped');
119+
}
120+
117121
return output + '\n';
118122
};
119123

lib/run-status.js

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class RunStatus extends EventEmitter {
5050
this.errors = [];
5151
this.stats = [];
5252
this.tests = [];
53+
this.failFastEnabled = opts.failFast || false;
5354

5455
autoBind(this);
5556
}

test/reporters/mini.js

+15
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,21 @@ test('results with unhandled errors', function (t) {
414414
t.end();
415415
});
416416

417+
test('results when fail-fast is enabled', function (t) {
418+
var reporter = miniReporter();
419+
var runStatus = {
420+
failFastEnabled: true
421+
};
422+
423+
var output = reporter.finish(runStatus);
424+
compareLineOutput(t, output, [
425+
'',
426+
'',
427+
' ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped')
428+
]);
429+
t.end();
430+
});
431+
417432
test('results with 1 previous failure', function (t) {
418433
var reporter = miniReporter();
419434
reporter.todoCount = 1;

test/reporters/verbose.js

+23
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,29 @@ test('results with errors', function (t) {
381381
t.end();
382382
});
383383

384+
test('results when fail-fast is enabled', function (t) {
385+
var reporter = verboseReporter();
386+
var runStatus = createRunStatus();
387+
runStatus.failCount = 1;
388+
runStatus.failFastEnabled = true;
389+
runStatus.tests = [{
390+
title: 'failed test'
391+
}];
392+
393+
var output = reporter.finish(runStatus);
394+
var expectedOutput = [
395+
'',
396+
' ' + chalk.red('1 test failed') + time,
397+
'',
398+
'',
399+
' ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped'),
400+
''
401+
].join('\n');
402+
403+
t.is(output, expectedOutput);
404+
t.end();
405+
});
406+
384407
test('results with 1 previous failure', function (t) {
385408
var reporter = createReporter();
386409

0 commit comments

Comments
 (0)