-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Bug: Tests pass without running after uncaught exception #5251
Comments
Hello@JoshuaKGoldberg
describe('b', function() {
it('should pass, then fail', function(done) {
process.nextTick(function() {
try {
throw new Error('uncaught!!');
} catch (err) {
done(err); // Mocha에 에러를 알림
}
});
});
});
describe('b', function() {
it('should pass, then fail', function() {
return new Promise((resolve, reject) => {
process.nextTick(function() {
reject(new Error('uncaught!!'));
});
});
});
}); |
I don't follow what you're asking, sorry. But if you can send a PR that would help me understand :) |
Hello sorry for leaving a reply so late, I try to do it every weekend but it's not easy haha In my opinion, the callback of process.nextTick() runs asynchronously, because there is no logic with the parameter "done" For example
So, how should we solve this? let's see this function.
If the parameter 'done' is included, the fn.length becomes 1 and it is recognized as an asynchronous function. For example
https://github.com/mochajs/mocha/blob/main/lib/runnable.js#L326 |
That seems reasonable at first glance. But it's hard to say without looking at a PR. I say: go for it, let's try it out! 🚀 |
Bug Report Checklist
faq
label, but none matched my issue.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
, andc
- andb
throws an error insideprocess.nextTick
. The report is:Minimal, Reproducible Example
https://github.com/JoshuaKGoldberg/repros/tree/mocha-skip-test-after-uncaught
Versions
Additional Info
Discovered in #5250 -> 6b5ff68.
Somewhat similar-looking to #5184 but not the same.
The text was updated successfully, but these errors were encountered: