-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
status: accepting prsMocha can use your help with this one!Mocha can use your help with this one!type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Description
Bug Report Checklist
- I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- I have searched for related issues and issues with the
faqlabel, 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
If an uncaught exception occurs, I would think Mocha should report a failure and continue running subsequent tests.
Actual
If a test throws an error inside a process.nextTick callback, Mocha correctly reports that test failing, but then doesn't run subsequent tests. It reports them as passed.
For example, in the MRE, there are three tests -a, b, and c- and b throws an error inside process.nextTick. The report is:
a
✔ should pass
b
✔ should pass, then fail
1) should pass, then fail
2 passing (3ms)
1 failing
1) b
should pass, then fail:
Uncaught Error: uncaught!!
at /Users/josh/repos/repros/test/example-b.js:4:15
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
Minimal, Reproducible Example
https://github.com/JoshuaKGoldberg/repros/tree/mocha-skip-test-after-uncaught
git clone https://github.com/JoshuaKGoldberg/repros -b mocha-skip-test-after-uncaught
npm i
npx mochaVersions
- Mocha: 10.8.2
- Node: 18, 20, and 22
Additional Info
Discovered in #5250 -> 6b5ff68.
Somewhat similar-looking to #5184 but not the same.
Metadata
Metadata
Assignees
Labels
status: accepting prsMocha can use your help with this one!Mocha can use your help with this one!type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Type
Projects
Status
No status