diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index cca5d826f..189ff63e2 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -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'; @@ -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); } diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index f3c59e012..82c0ab873 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -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) { @@ -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); } diff --git a/lib/serialize-error.js b/lib/serialize-error.js index bd25c7f56..611223d0f 100644 --- a/lib/serialize-error.js +++ b/lib/serialize-error.js @@ -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;