Skip to content

Commit

Permalink
Simplify failure output - fixes #1072 (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
LasaleFamine authored and sindresorhus committed Feb 14, 2017
1 parent 2c683b9 commit da68f29
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
5 changes: 4 additions & 1 deletion lib/reporters/mini.js
Expand Up @@ -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);
}
}
});
}
Expand Down
5 changes: 4 additions & 1 deletion lib/reporters/verbose.js
Expand Up @@ -123,7 +123,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);
}
}
});
}
Expand Down
16 changes: 4 additions & 12 deletions test/reporters/mini.js
Expand Up @@ -409,9 +409,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();
});
Expand Down Expand Up @@ -470,9 +468,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();
});
Expand Down Expand Up @@ -534,9 +530,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();
});
Expand Down Expand Up @@ -599,9 +593,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();
});
Expand Down
16 changes: 4 additions & 12 deletions test/reporters/verbose.js
Expand Up @@ -416,9 +416,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();
});
Expand Down Expand Up @@ -474,9 +472,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();
});
Expand Down Expand Up @@ -535,9 +531,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();
});
Expand Down Expand Up @@ -597,9 +591,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();
});
Expand Down

0 comments on commit da68f29

Please sign in to comment.