feat: support reporting AggregateErrors
Requirements
- Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
- All new code requires tests to ensure against regressions.
Description of the Change
Addresses #4982 If an AggregateError is thrown, the base reporter will print out the AggregateError's errors. Before this change, only the Aggregate Error itself was printed. So, if the current error being printed is an Aggregate error the errors it contains will also be formatted and printed.
Alternate Designs
I could have completely restructured the Base.list method to only loop over the failures and call a helper function that would create the format(fmt), msg, and title and then print the error, but it was much simpler to just add a conditional check to see if the current error being printed was an AggregateError and if it contained multiple errors and just
Why should this be in core?
Currently, nothing nice prints. When dealing with AggregateErrors it would be better if each subsequent error was printed and formatted as well.
Benefits
The errors within the AggregateError will be nicely formatted when printed.
Possible Drawbacks
If an AggregateError contains a lot of errors, then a lot of errors will be printed!
Applicable issues
Nothing of note.
Plus one on this. I just ran into it. Is anyone working on this anymore? It looks like maybe the feedback was addressed?
Somewhere between Node 16 and Node 20, Node's own APIs started throwing AggregateError in certain cases, e.g. network failures when autoSelectFamily === true (the default). Without proper formatting, it's very difficult to debug such errors when they occur in Mocha tests. Is there anything we can do to help this along?
I addressed all the changes and sent an email to voxpelli to see if he could approve it.
I'll try to get around to it soon, else eg. @JoshuaKGoldberg can chime in?
I'm running out of time to review and merge this today, but this one together with these two are my main priority right now:
- https://github.com/mochajs/mocha/pull/5074
- #4829