Skip to content

Commit

Permalink
Base#epilogue(): test with multiple errors
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Oct 13, 2019
1 parent 2aef07d commit 679800e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ var generateDiff = (exports.generateDiff = function(actual, expected) {
* Error property
*/
exports.list = function(failures) {
var multipleErr, multipleTest;
Base.consoleLog();
failures.forEach(function(test, i) {
// format
Expand All @@ -207,7 +208,16 @@ exports.list = function(failures) {

// msg
var msg;
var err = test.err;
var err;
if (test.err && test.err.multiple) {
if (multipleTest !== test) {
multipleTest = test;
multipleErr = [test.err].concat(test.err.multiple);
}
err = multipleErr.shift();
} else {
err = test.err;
}
var message;
if (err.message && typeof err.message.toString === 'function') {
message = err.message + '';
Expand Down Expand Up @@ -298,7 +308,12 @@ function Base(runner, options) {
if (showDiff(err)) {
stringifyDiffObjs(err);
}
test.err = err;
// more than one error per test
if (test.err && err instanceof Error) {
test.err.multiple = (test.err.multiple || []).concat(err);
} else {
test.err = err;
}
failures.push(test);
});
}
Expand Down

0 comments on commit 679800e

Please sign in to comment.