Skip to content

fix: report sync error thrown after done() in async tests #5991

Open
mostafaNazari702 wants to merge 1 commit into
mochajs:mainfrom
mostafaNazari702:sync-after-done
Open

fix: report sync error thrown after done() in async tests #5991
mostafaNazari702 wants to merge 1 commit into
mochajs:mainfrom
mostafaNazari702:sync-after-done

Conversation

@mostafaNazari702
Copy link
Copy Markdown
Contributor

PR Checklist

Overview

Tests using done() could incorrectly pass if they called it synchronosly and then immediately threw an error afterward. Caused by the post-done() throw being treated as already handled that silently swallowed the error ( excuse me for the unprofessional way of describing ).

this fix detects throws that happen after done() completes and routes them through mocha’s existing multiple-done error handling causing the test to fail correctly and inntegration tests were added to verify the failure behavior and error message.

@mostafaNazari702 mostafaNazari702 changed the title fix: report sync error thrown after done() in async tests fix: report sync error thrown after done() in async tests May 22, 2026
@mostafaNazari702
Copy link
Copy Markdown
Contributor Author

Added a space in the end of the title to rerun tests.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.89%. Comparing base (6695fba) to head (90b9e47).

Files with missing lines Patch % Lines
lib/runnable.mjs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5991      +/-   ##
==========================================
- Coverage   80.89%   80.89%   -0.01%     
==========================================
  Files          64       64              
  Lines        4602     4605       +3     
  Branches      976      996      +20     
==========================================
+ Hits         3723     3725       +2     
- Misses        879      880       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug: Test stops recognizing exceptions once done has been called

1 participant