Skip to content

Commit e542d20

Browse files
author
Thomas
committed
Print out warning in verbose and mini reporter when --fail-fast is enabled
1 parent 8171dbc commit e542d20

File tree

8 files changed

+52
-3
lines changed

8 files changed

+52
-3
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: options.failFast
149150
});
150151

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

lib/cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ exports.run = function () {
160160
}
161161
}
162162
} else {
163-
api.run(files)
163+
api.run(files, {failFast: cli.flags.failFast})
164164
.then(function (runStatus) {
165165
logger.finish(runStatus);
166166
logger.exit(runStatus.failCount > 0 || runStatus.rejectionCount > 0 || runStatus.exceptionCount > 0 ? 1 : 0);

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
@@ -220,6 +220,10 @@ MiniReporter.prototype.finish = function (runStatus) {
220220
});
221221
}
222222

223+
if (runStatus.failFastEnabled === true) {
224+
status += '\n\n ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped');
225+
}
226+
223227
return status + '\n\n';
224228
};
225229

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
@@ -383,6 +383,21 @@ test('results with errors', function (t) {
383383
t.end();
384384
});
385385

386+
test('results when fail-fast is enabled', function (t) {
387+
var reporter = miniReporter();
388+
var runStatus = {
389+
failFastEnabled: true
390+
};
391+
392+
var output = reporter.finish(runStatus);
393+
compareLineOutput(t, output, [
394+
'',
395+
'',
396+
' ' + colors.failFast('`--fail-fast` is on. Any number of tests may have been skipped')
397+
]);
398+
t.end();
399+
});
400+
386401
test('results with 1 previous failure', function (t) {
387402
var reporter = miniReporter();
388403
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)