Skip to content

Commit

Permalink
show error stack if present
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Demedes committed Jan 19, 2017
1 parent 9b5f650 commit 38ec942
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions lib/reporters/mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ MiniReporter.prototype.finish = function (runStatus) {
}

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

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

status += '\n' + indentString(test.error.message, 2) + '\n';
status += '\n' + indentString(colors.errorStack(description), 2);

if (test.error.stack) {
status += '\n' + indentString(colors.errorStack(extractStack(test.error.stack)), 2);
}
}, this);
}

Expand Down
5 changes: 3 additions & 2 deletions lib/reporters/verbose.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ VerboseReporter.prototype.finish = function (runStatus) {
return;
}

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

output += '\n' + indentString(test.error.message, 2) + '\n';
output += '\n' + indentString(colors.errorStack(stack), 2);
if (test.error.stack) {
output += '\n' + indentString(colors.errorStack(extractStack(test.error.stack)), 2);
}
}, this);
}

Expand Down
16 changes: 9 additions & 7 deletions lib/serialize-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ const stackUtils = new StackUtils();
module.exports = error => {
const err = cleanYamlObject(error, filter);

const firstStackLine = extractStack(err.stack).split('\n')[0];
const source = stackUtils.parseLine(firstStackLine);
if (source) {
err.source = {
file: source.file.trim(),
line: source.line
};
if (err.stack) {
const firstStackLine = extractStack(err.stack).split('\n')[0];
const source = stackUtils.parseLine(firstStackLine);
if (source) {
err.source = {
file: source.file.trim(),
line: source.line
};
}
}

return err;
Expand Down

0 comments on commit 38ec942

Please sign in to comment.