Skip to content

Commit 8a67704

Browse files
mcmathjasindresorhus
authored andcommitted
Close #303 PR: Adds filename to failed test title.. Fixes #272
1 parent 94d2dc3 commit 8a67704

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ api.run()
9191
log.write();
9292

9393
if (api.failCount > 0) {
94-
log.errors(api.tests);
94+
log.errors(api.errors);
9595
}
9696

9797
process.stdout.write('');

lib/logger.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,14 @@ x.test = function (props) {
5252
log.success(props.title + dur);
5353
};
5454

55-
x.errors = function (results) {
55+
x.errors = function (tests) {
5656
var i = 0;
5757

58-
results.forEach(function (result) {
59-
if (!(result.error && result.error.message)) {
60-
return;
61-
}
62-
58+
tests.forEach(function (test) {
6359
i++;
6460

65-
log.writelpad(chalk.red(i + '.', result.title));
66-
log.writelpad(chalk.red(beautifyStack(result.error.stack)));
61+
log.writelpad(chalk.red(i + '.', test.title));
62+
log.writelpad(chalk.red(beautifyStack(test.error.stack)));
6763
log.write();
6864
});
6965
};

test/cli.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ test('display test title prefixes', function (t) {
8989
});
9090
});
9191

92+
test('display filename prefixes for failed test stack traces', function (t) {
93+
t.plan(2);
94+
95+
execCli(['fixture/es2015.js', 'fixture/one-pass-one-fail.js'], function (err, stdout, stderr) {
96+
t.ok(err);
97+
t.match(stderr, /^.*1\. one-pass-one-fail.*this is a failing test.*$/m);
98+
t.end();
99+
});
100+
});
101+
92102
test('don\'t display test title if there is only one anonymous test', function (t) {
93103
t.plan(2);
94104

0 commit comments

Comments
 (0)