Skip to content

Commit

Permalink
Removed unused lines of code and added a test to verify that the beha…
Browse files Browse the repository at this point in the history
…vior is still the same
  • Loading branch information
jarlehansen committed Jan 4, 2017
1 parent 8171dbc commit d78f63c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/reporters/mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ MiniReporter.prototype.finish = function (runStatus) {
var errorTitle = ' ' + test.error.message + '\n';
var isPowerAssert = test.error.message.split('\n').length > 1;

if (test.error) {
description = stripFirstLine(test.error.stack).trimRight();
} else {
description = JSON.stringify(test);
}
description = stripFirstLine(test.error.stack).trimRight();

if (isPowerAssert) {
description = stripFirstLine(description).replace(/ {3}/g, ' ');
Expand Down
31 changes: 31 additions & 0 deletions test/reporters/mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,37 @@ test('results with errors', function (t) {
t.end();
});

test('results with unhandled errors', function (t) {
var reporter = miniReporter();
reporter.failCount = 2;

var err = new Error('failure one');
err.stack = beautifyStack(err.stack);

var runStatus = {
errors: [
{title: 'failed one', error: err},
{title: 'failed two'}
]
};

var output = reporter.finish(runStatus);
var expectedStack = colors.error(' failure two\n') + colors.errorStack('stack line with trailing whitespace');

compareLineOutput(t, output, [
'',
' ' + chalk.red('2 failed'),
'',
' ' + chalk.white('failed one'),
/failure/,
/test\/reporters\/mini\.js/,
compareLineOutput.SKIP_UNTIL_EMPTY_LINE,
'',
''
].concat(expectedStack.split('\n')));
t.end();
});

test('results with 1 previous failure', function (t) {
var reporter = miniReporter();
reporter.todoCount = 1;
Expand Down

0 comments on commit d78f63c

Please sign in to comment.