Skip to content

Commit 38ec942

Browse files
author
Vadim Demedes
committed
show error stack if present
1 parent 9b5f650 commit 38ec942

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

lib/reporters/mini.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ MiniReporter.prototype.finish = function (runStatus) {
180180
}
181181

182182
var title = test.error ? test.title : 'Unhandled Error';
183-
var description = extractStack(test.error.stack);
184183
var beforeSpacing = index === 0 ? '\n\n' : '\n\n\n\n';
185184

186185
status += beforeSpacing + ' ' + colors.title(title) + '\n';
@@ -195,7 +194,10 @@ MiniReporter.prototype.finish = function (runStatus) {
195194
}
196195

197196
status += '\n' + indentString(test.error.message, 2) + '\n';
198-
status += '\n' + indentString(colors.errorStack(description), 2);
197+
198+
if (test.error.stack) {
199+
status += '\n' + indentString(colors.errorStack(extractStack(test.error.stack)), 2);
200+
}
199201
}, this);
200202
}
201203

lib/reporters/verbose.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ VerboseReporter.prototype.finish = function (runStatus) {
110110
return;
111111
}
112112

113-
var stack = extractStack(test.error.stack);
114113
var beforeSpacing = index === 0 ? '\n\n' : '\n\n\n\n';
115114
output += beforeSpacing + ' ' + colors.title(test.title) + '\n';
116115
if (test.error.source) {
@@ -124,7 +123,9 @@ VerboseReporter.prototype.finish = function (runStatus) {
124123
}
125124

126125
output += '\n' + indentString(test.error.message, 2) + '\n';
127-
output += '\n' + indentString(colors.errorStack(stack), 2);
126+
if (test.error.stack) {
127+
output += '\n' + indentString(colors.errorStack(extractStack(test.error.stack)), 2);
128+
}
128129
}, this);
129130
}
130131

lib/serialize-error.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ const stackUtils = new StackUtils();
5555
module.exports = error => {
5656
const err = cleanYamlObject(error, filter);
5757

58-
const firstStackLine = extractStack(err.stack).split('\n')[0];
59-
const source = stackUtils.parseLine(firstStackLine);
60-
if (source) {
61-
err.source = {
62-
file: source.file.trim(),
63-
line: source.line
64-
};
58+
if (err.stack) {
59+
const firstStackLine = extractStack(err.stack).split('\n')[0];
60+
const source = stackUtils.parseLine(firstStackLine);
61+
if (source) {
62+
err.source = {
63+
file: source.file.trim(),
64+
line: source.line
65+
};
66+
}
6567
}
6668

6769
return err;

0 commit comments

Comments
 (0)