Skip to content

--fail-zero respects --delay test registration#5992

Open
mostafaNazari702 wants to merge 1 commit into
mochajs:mainfrom
mostafaNazari702:failzero-delay
Open

--fail-zero respects --delay test registration#5992
mostafaNazari702 wants to merge 1 commit into
mochajs:mainfrom
mostafaNazari702:failzero-delay

Conversation

@mostafaNazari702

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

So --fail-zero + --delay was incorrectly failing runs with exit code 1 even when tests actually executed fine.

the issue was that Runner captures this.total in the constructor but with --delay the tests dont exist yet at that point and they're only registered later when the user's deferred callback runs. so the runner thinks there are 0 tests the whole time.
then --fail-zero kicks in at the end and says “no tests ran => fail the run” even though tests actually did run.

i chose to, instead of trusting the constructor value, we recompute this.total in prepare() right after the delayed setup has finished and just before execution starts. that way it reflects the real suite (including --grep / --invert filtering).

So basically: we just move the "count the tests" moment to when the tests actually exist.

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.90%. Comparing base (6695fba) to head (5e0b880).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5992   +/-   ##
=======================================
  Coverage   80.89%   80.90%           
=======================================
  Files          64       64           
  Lines        4602     4603    +1     
  Branches      976      976           
=======================================
+ Hits         3723     3724    +1     
  Misses        879      879           

☔ 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: --fail-zero always fails the test run when --delay is also used

1 participant