From 48ea6d5fe4c5b6864b1c74beca823d19c29cfb1d Mon Sep 17 00:00:00 2001 From: LasaleFamine Date: Mon, 6 Feb 2017 22:08:25 +0100 Subject: [PATCH 1/3] Start with check the `mini` reporter --- lib/reporters/mini.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 97119fd23..f65a8ef93 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -203,7 +203,7 @@ class MiniReporter { status += '\n' + indentString(test.error.message, 2) + '\n'; } - if (test.error.stack) { + if (test.error.stack && test.error.source.file !== test.file) { status += '\n' + indentString(colors.errorStack(extractStack(test.error.stack)), 2); } }); From e1a98e39226fb307a1ba7d927c1e430f1ec66ca3 Mon Sep 17 00:00:00 2001 From: LasaleFamine Date: Wed, 8 Feb 2017 20:46:12 +0100 Subject: [PATCH 2/3] Changed `mini` check and added `verbose` check --- lib/reporters/mini.js | 7 +++++-- lib/reporters/verbose.js | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index f65a8ef93..8a622a8d7 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -203,8 +203,11 @@ class MiniReporter { status += '\n' + indentString(test.error.message, 2) + '\n'; } - if (test.error.stack && test.error.source.file !== test.file) { - status += '\n' + indentString(colors.errorStack(extractStack(test.error.stack)), 2); + if (test.error.stack) { + 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); + } } }); } From 428cd013ab7cffc5c2cb3f6b1d3134719a00a995 Mon Sep 17 00:00:00 2001 From: LasaleFamine Date: Wed, 8 Feb 2017 21:13:41 +0100 Subject: [PATCH 3/3] Fixed `mini` and `verbose` reporters tests --- test/reporters/mini.js | 16 ++++------------ test/reporters/verbose.js | 16 ++++------------ 2 files changed, 8 insertions(+), 24 deletions(-) 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(); });