Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print out warning in verbose & mini reporter when --fail-fast is enabled #1160

Merged
merged 1 commit into from
Jan 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion lib/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
4 changes: 4 additions & 0 deletions lib/reporters/mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};

Expand Down
4 changes: 4 additions & 0 deletions lib/reporters/verbose.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};

Expand Down
1 change: 1 addition & 0 deletions lib/run-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class RunStatus extends EventEmitter {
this.errors = [];
this.stats = [];
this.tests = [];
this.failFastEnabled = opts.failFast || false;

autoBind(this);
}
Expand Down
15 changes: 15 additions & 0 deletions test/reporters/mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions test/reporters/verbose.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down