Skip to content

Commit

Permalink
fix: improve error handling in global fixtures mochajs#5208
Browse files Browse the repository at this point in the history
  • Loading branch information
TG199 committed Dec 19, 2024
1 parent 6caa902 commit b9874b5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ Mocha.prototype.failZero = function (failZero) {
* @return {Mocha} this
* @chainable
*/
Mocha.prototype.passOnFailingTestSuite = function(passOnFailingTestSuite) {
Mocha.prototype.passOnFailingTestSuite = function (passOnFailingTestSuite) {
this.options.passOnFailingTestSuite = passOnFailingTestSuite === true;
return this;
};
Expand Down Expand Up @@ -1229,8 +1229,12 @@ Mocha.prototype._runGlobalFixtures = async function _runGlobalFixtures(
fixtureFns = [],
context = {}
) {
for await (const fixtureFn of fixtureFns) {
await fixtureFn.call(context);
for (const fixtureFn of fixtureFns) {
try {
await fixtureFn.call(context);
} catch (err) {
console.error(err.stack);
}
}
return context;
};
Expand Down

0 comments on commit b9874b5

Please sign in to comment.