Open
Description
Bug Report Checklist
- I have read and agree to Mocha's Code of Conduct and Contributing GuidelinesI have searched for related issues and issues with the
faq
label, but none matched my issue.I have 'smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, my usage of Mocha, or Mocha itself.I want to provide a PR to resolve this
Expected
The error should be logged and the tests should exit with a non-zero exit code
Actual
The error is swallowed and the tests always exit with a 0 exit code (even if some tests failed)
Minimal, Reproducible Example
// test.js
const { it } = require("mocha");
it("should work", () => {
throw new Error("It doesn't work");
});
// setup.js
exports.mochaGlobalTeardown = async function () {
throw new Error("Teardown problem");
};
$ npx mocha -r setup.js test.js
Versions
Mocha v10.7.3, Node v20.15.1
Additional Info
No response
Activity
JoshuaKGoldberg commentedon Oct 8, 2024
👍 Agreed, this is a bug. I reproduced it by adding the
throw new Error("Teardown problem");
to theexports.mochaGlobalTeardown
in mochajs/mocha-examples#101.fix: improve error handling in global fixtures mochajs#5208