diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 97119fd23..8a622a8d7 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -204,7 +204,10 @@ class MiniReporter { } if (test.error.stack) { - status += '\n' + indentString(colors.errorStack(extractStack(test.error.stack)), 2); + const extracted = extractStack(test.error.stack); + if (extracted.includes('\n')) { + status += '\n' + indentString(colors.errorStack(extracted), 2); + } } }); } diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index 6a92606bd..eb03007da 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -122,7 +122,10 @@ class VerboseReporter { } if (test.error.stack) { - output += '\n' + indentString(colors.errorStack(extractStack(test.error.stack)), 2); + const extracted = extractStack(test.error.stack); + if (extracted.includes('\n')) { + output += '\n' + indentString(colors.errorStack(extracted), 2); + } } }); } diff --git a/test/reporters/mini.js b/test/reporters/mini.js index 934b0ce8d..e9a411e8d 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -406,9 +406,7 @@ test('results with errors', t => { indentString(codeExcerpt(err2Path, err2.source.line), 2).split('\n'), '', indentString(formatAssertError(err2), 2).split('\n'), - /failure two/, - '', - stackLineRegex + /failure two/ ])); t.end(); }); @@ -467,9 +465,7 @@ test('results with errors and disabled code excerpts', t => { indentString(codeExcerpt(err2Path, err2.source.line), 2).split('\n'), '', indentString(formatAssertError(err2), 2).split('\n'), - /failure two/, - '', - stackLineRegex + /failure two/ ])); t.end(); }); @@ -531,9 +527,7 @@ test('results with errors and broken code excerpts', t => { indentString(codeExcerpt(err2Path, err2.source.line), 2).split('\n'), '', indentString(formatAssertError(err2), 2).split('\n'), - /failure two/, - '', - stackLineRegex + /failure two/ ])); t.end(); }); @@ -596,9 +590,7 @@ test('results with errors and disabled assert output', t => { indentString(codeExcerpt(err2Path, err2.source.line), 2).split('\n'), '', indentString(formatAssertError(err2), 2).split('\n'), - /failure two/, - '', - stackLineRegex + /failure two/ ])); t.end(); }); diff --git a/test/reporters/verbose.js b/test/reporters/verbose.js index 2602af972..57d82a228 100644 --- a/test/reporters/verbose.js +++ b/test/reporters/verbose.js @@ -413,9 +413,7 @@ test('results with errors', t => { indentString(codeExcerpt(err2Path, error2.source.line), 2).split('\n'), '', indentString(formatAssertError(error2), 2).split('\n'), - /error two message/, - '', - stackLineRegex + /error two message/ ])); t.end(); }); @@ -471,9 +469,7 @@ test('results with errors and disabled code excerpts', t => { indentString(codeExcerpt(err2Path, error2.source.line), 2).split('\n'), '', indentString(formatAssertError(error2), 2).split('\n'), - /error two message/, - '', - stackLineRegex + /error two message/ ])); t.end(); }); @@ -532,9 +528,7 @@ test('results with errors and disabled code excerpts', t => { indentString(codeExcerpt(err2Path, error2.source.line), 2).split('\n'), '', indentString(formatAssertError(error2), 2).split('\n'), - /error two message/, - '', - stackLineRegex + /error two message/ ])); t.end(); }); @@ -594,9 +588,7 @@ test('results with errors and disabled assert output', t => { indentString(codeExcerpt(err2Path, error2.source.line), 2).split('\n'), '', indentString(formatAssertError(error2), 2).split('\n'), - /error two message/, - '', - stackLineRegex + /error two message/ ])); t.end(); });