Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CheadleCheadle committed Mar 4, 2024
1 parent f974e01 commit b04709c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/cli/run-option-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ exports.aliases = {
ignore: ['exclude'],
invert: ['i'],
jobs: ['j'],
jsonStringifyWhitespace: ['jsw'],
'no-colors': ['C'],
'node-option': ['n'],
parallel: ['p'],
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ exports.list = function (failures) {

// indented test title
var testTitle = '';
// Incase test is an AggregateError object when recursively listing errors

if (test instanceof AggregateError) {
test.titlePath().forEach(function (str, index) {
if (index !== 0) {
Expand Down
39 changes: 38 additions & 1 deletion test/reporters/base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,44 @@ describe('Base reporter', function () {

var errOut = stdout.join('\n').trim();

expect(errOut, 'to contain', ' Error: 1', 'Error: 2');
// Handle removing system's specific error callStack
errOut = errOut
.split('\n')
.filter(line => !line.trim().startsWith('at '))
.join('\n')
.replace(/\n/g, '');

var expectedFormat = `1) : ${aggErr.name}: ${aggErr.message} 1) : ${err1.name}: ${err1.message} 2) : ${err2.name}: ${err2.message}`;

expect(errOut, 'to equal', expectedFormat);
});

it('should handle Aggregate Error Objects with 0 errors properly', function () {
var aggErr = new AggregateError([], ' 0 errors');

var test = makeTest(aggErr);
list([test]);

var errOut = stdout.join('\n').trim();

var expectedFormat = aggErr.name + ': ' + aggErr.message;

expect(errOut, 'to contain', expectedFormat);
});

it('should handle non-Error types properly', function () {
var nonError = {name: 'NotAnError', message: 'This is not an error object'};
var aggErr = new AggregateError([nonError]);

var test = makeTest(aggErr);
list([test]);

assert.strictEqual(aggErr.errors.length, 1, 'Should contain one error');
assert.strictEqual(
aggErr.errors[0],
nonError,
'The non-Error object should be preserved in the errors array'
);
});
});

Expand Down

0 comments on commit b04709c

Please sign in to comment.