Skip to content

Commit b9874b5

Browse files
committed
fix: improve error handling in global fixtures #5208
1 parent 6caa902 commit b9874b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/mocha.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ Mocha.prototype.failZero = function (failZero) {
881881
* @return {Mocha} this
882882
* @chainable
883883
*/
884-
Mocha.prototype.passOnFailingTestSuite = function(passOnFailingTestSuite) {
884+
Mocha.prototype.passOnFailingTestSuite = function (passOnFailingTestSuite) {
885885
this.options.passOnFailingTestSuite = passOnFailingTestSuite === true;
886886
return this;
887887
};
@@ -1229,8 +1229,12 @@ Mocha.prototype._runGlobalFixtures = async function _runGlobalFixtures(
12291229
fixtureFns = [],
12301230
context = {}
12311231
) {
1232-
for await (const fixtureFn of fixtureFns) {
1233-
await fixtureFn.call(context);
1232+
for (const fixtureFn of fixtureFns) {
1233+
try {
1234+
await fixtureFn.call(context);
1235+
} catch (err) {
1236+
console.error(err.stack);
1237+
}
12341238
}
12351239
return context;
12361240
};

0 commit comments

Comments
 (0)