diff --git a/api.js b/api.js index a2377ba4c..ef7c97034 100644 --- a/api.js +++ b/api.js @@ -145,7 +145,8 @@ Api.prototype._run = function (files, options) { var runStatus = new RunStatus({ runOnlyExclusive: options.runOnlyExclusive, prefixTitles: this.options.explicitTitles || files.length > 1, - base: path.relative('.', commonPathPrefix(files)) + path.sep + base: path.relative('.', commonPathPrefix(files)) + path.sep, + failFast: this.options.failFast }); this.emit('test-run', runStatus, files); diff --git a/lib/colors.js b/lib/colors.js index 2d67c9808..4c004e001 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -9,5 +9,6 @@ module.exports = { pass: chalk.green, duration: chalk.gray.dim, errorStack: chalk.gray, - stack: chalk.red + stack: chalk.red, + failFast: chalk.magenta }; diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index c78e758e4..290f25590 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -216,6 +216,10 @@ MiniReporter.prototype.finish = function (runStatus) { }); } + if (runStatus.failFastEnabled === true) { + status += '\n\n ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped'); + } + return status + '\n\n'; }; diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index a81860178..3905d4de7 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -114,6 +114,10 @@ VerboseReporter.prototype.finish = function (runStatus) { }); } + if (runStatus.failFastEnabled === true) { + output += '\n\n\n ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped'); + } + return output + '\n'; }; diff --git a/lib/run-status.js b/lib/run-status.js index 4c20ed6a3..7c8cc306b 100644 --- a/lib/run-status.js +++ b/lib/run-status.js @@ -50,6 +50,7 @@ class RunStatus extends EventEmitter { this.errors = []; this.stats = []; this.tests = []; + this.failFastEnabled = opts.failFast || false; autoBind(this); } diff --git a/test/reporters/mini.js b/test/reporters/mini.js index ec73396fb..e4cc1d6e4 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -414,6 +414,21 @@ test('results with unhandled errors', function (t) { t.end(); }); +test('results when fail-fast is enabled', function (t) { + var reporter = miniReporter(); + var runStatus = { + failFastEnabled: true + }; + + var output = reporter.finish(runStatus); + compareLineOutput(t, output, [ + '', + '', + ' ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped') + ]); + t.end(); +}); + test('results with 1 previous failure', function (t) { var reporter = miniReporter(); reporter.todoCount = 1; diff --git a/test/reporters/verbose.js b/test/reporters/verbose.js index 14641f0cc..5906bbc88 100644 --- a/test/reporters/verbose.js +++ b/test/reporters/verbose.js @@ -381,6 +381,29 @@ test('results with errors', function (t) { t.end(); }); +test('results when fail-fast is enabled', function (t) { + var reporter = verboseReporter(); + var runStatus = createRunStatus(); + runStatus.failCount = 1; + runStatus.failFastEnabled = true; + runStatus.tests = [{ + title: 'failed test' + }]; + + var output = reporter.finish(runStatus); + var expectedOutput = [ + '', + ' ' + chalk.red('1 test failed') + time, + '', + '', + ' ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped'), + '' + ].join('\n'); + + t.is(output, expectedOutput); + t.end(); +}); + test('results with 1 previous failure', function (t) { var reporter = createReporter();