From e30685f233a1328862533439aa8f8a31447a6212 Mon Sep 17 00:00:00 2001 From: vdemedes Date: Sun, 27 Dec 2015 23:31:04 +0200 Subject: [PATCH] display power-assert output in mini reporter --- lib/reporters/mini.js | 13 ++++++++++--- test/reporters/mini.js | 7 ++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 7f4d6efa7..83e29db2d 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -82,7 +82,7 @@ MiniReporter.prototype.finish = function () { var i = 0; if (this.failCount > 0) { - this.api.tests.forEach(function (test) { + this.api.errors.forEach(function (test) { if (!test.error || !test.error.message) { return; } @@ -90,10 +90,17 @@ MiniReporter.prototype.finish = function () { i++; var title = test.error ? test.title : 'Unhandled Error'; - var description = test.error ? beautifyStack(test.error.stack) : JSON.stringify(test); + var description; + + if (test.error) { + description = ' ' + test.error.message; + description += '\n ' + beautifyStack(test.error.stack); + } else { + description = JSON.stringify(test); + } status += '\n\n ' + chalk.red(i + '.', title) + '\n'; - status += ' ' + chalk.red(description); + status += chalk.red(description); }); } diff --git a/test/reporters/mini.js b/test/reporters/mini.js index ccfafed02..91599ce0d 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -137,7 +137,7 @@ test('results with errors', function (t) { reporter.failCount = 1; reporter.api = { - tests: [{ + errors: [{ title: 'failed', error: new Error('failure') }] @@ -149,7 +149,8 @@ test('results with errors', function (t) { t.is(output[1], ' ' + chalk.red('1 failed')); t.is(output[2], ''); t.is(output[3], ' ' + chalk.red('1. failed')); - t.match(output[4], /Error: failure/); - t.match(output[5], /Test\.test/); + t.match(output[4], /failure/); + t.match(output[5], /Error: failure/); + t.match(output[6], /Test\.test/); t.end(); });