Skip to content

Commit 5aeb270

Browse files
committed
Merge pull request #380 from sindresorhus/power-assert-in-mini
Display power-assert output in mini reporter
2 parents 437e88f + e30685f commit 5aeb270

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lib/reporters/mini.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,25 @@ MiniReporter.prototype.finish = function () {
8282
var i = 0;
8383

8484
if (this.failCount > 0) {
85-
this.api.tests.forEach(function (test) {
85+
this.api.errors.forEach(function (test) {
8686
if (!test.error || !test.error.message) {
8787
return;
8888
}
8989

9090
i++;
9191

9292
var title = test.error ? test.title : 'Unhandled Error';
93-
var description = test.error ? beautifyStack(test.error.stack) : JSON.stringify(test);
93+
var description;
94+
95+
if (test.error) {
96+
description = ' ' + test.error.message;
97+
description += '\n ' + beautifyStack(test.error.stack);
98+
} else {
99+
description = JSON.stringify(test);
100+
}
94101

95102
status += '\n\n ' + chalk.red(i + '.', title) + '\n';
96-
status += ' ' + chalk.red(description);
103+
status += chalk.red(description);
97104
});
98105
}
99106

test/reporters/mini.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ test('results with errors', function (t) {
137137
reporter.failCount = 1;
138138

139139
reporter.api = {
140-
tests: [{
140+
errors: [{
141141
title: 'failed',
142142
error: new Error('failure')
143143
}]
@@ -149,7 +149,8 @@ test('results with errors', function (t) {
149149
t.is(output[1], ' ' + chalk.red('1 failed'));
150150
t.is(output[2], '');
151151
t.is(output[3], ' ' + chalk.red('1. failed'));
152-
t.match(output[4], /Error: failure/);
153-
t.match(output[5], /Test\.test/);
152+
t.match(output[4], /failure/);
153+
t.match(output[5], /Error: failure/);
154+
t.match(output[6], /Test\.test/);
154155
t.end();
155156
});

0 commit comments

Comments
 (0)