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 ca9eb64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 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
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 ca9eb64

Please sign in to comment.