From c84694bb898e24bf804e3cd0360c59ca7725ba8a Mon Sep 17 00:00:00 2001 From: Jarle Hansen Date: Thu, 5 Jan 2017 11:58:48 +0100 Subject: [PATCH] Removed unused code in mini reporter (#1169) --- lib/reporters/mini.js | 6 +----- test/reporters/mini.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index ac29a2f16..c78e758e4 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -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, ' '); diff --git a/test/reporters/mini.js b/test/reporters/mini.js index 161f0817e..ec73396fb 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -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;