Skip to content

Commit d6fed1c

Browse files
committed
regression: logger throws on files with both passing and failing tests.
log.errors() cycles through all the results from a file (passing and failing) and prints out a summary of the failing tests and the assertion errors. It was misidentfying all results as errors, and then throwing when result.error turned out to be an empty object ({}). I think the result object can be improved such that result.error === false when there were no errors. But that is for another PR.
1 parent 8645916 commit d6fed1c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lib/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ x.errors = function (results) {
5858
var i = 0;
5959

6060
results.forEach(function (result) {
61-
if (!result.error) {
61+
if (!(result.error && result.error.message)) {
6262
return;
6363
}
6464

test/fixture/one-pass-one-fail.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const test = require('../../');
2+
3+
test('this is a passing test', t => {
4+
t.ok(true);
5+
t.end();
6+
});
7+
8+
test('this is a failing test', t => {
9+
t.ok(false);
10+
t.end();
11+
});

test/test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,3 +1075,15 @@ test('absolute paths in CLI', function (t) {
10751075
t.end();
10761076
});
10771077
});
1078+
1079+
test('titles of both passing and failing tests and AssertionErrors are displayed', function (t) {
1080+
t.plan(4);
1081+
1082+
execCli('fixture/one-pass-one-fail.js', function (err, stdout, stderr) {
1083+
t.ok(err);
1084+
t.ok(/this is a passing test/.test(stderr));
1085+
t.ok(/this is a failing test/.test(stderr));
1086+
t.ok(/AssertionError/.test(stderr));
1087+
t.end();
1088+
});
1089+
});

0 commit comments

Comments
 (0)