Skip to content

fix: show spec reporter failures at the correct indent level#5888

Open
mostafaNazari702 wants to merge 1 commit into
mochajs:mainfrom
mostafaNazari702:fix/spec-reporter-fail-indent
Open

fix: show spec reporter failures at the correct indent level#5888
mostafaNazari702 wants to merge 1 commit into
mochajs:mainfrom
mostafaNazari702:fix/spec-reporter-fail-indent

Conversation

@mostafaNazari702
Copy link
Copy Markdown
Contributor

PR Checklist

Overview

So there was this weird issue with how failures showed up in the spec reporter.

If an async error popped up after a test had already passed, the runner would go back and mark that test as failed. Totally fine, but the way it was displayed was off. The reporter was using this running counter to figure out indentation, and that counter just follows whatever suite is currently being entered or exited, not the suite the failed test actually belongs to.

You'd end up with failures showing at the wrong level, which made the whole output kind of confusing to read.

The fix walks up test.parent to the root suite to figure out the real depth. If that info isn't available (like in parallel mode without linkPartialObjects, or with mocked test objects), it falls back to the old counter so things don't break.

Also added a fixture and integration test to recreate that async error situation across suites, just to make sure it's properly covered now.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.90%. Comparing base (724fb50) to head (912292e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5888      +/-   ##
==========================================
+ Coverage   80.85%   80.90%   +0.04%     
==========================================
  Files          64       64              
  Lines        4566     4576      +10     
  Branches      977      960      -17     
==========================================
+ Hits         3692     3702      +10     
  Misses        874      874              

☔ 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.

Copy link
Copy Markdown
Member

@mark-wiemer mark-wiemer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one qq

Comment thread test/integration/uncaught.spec.js Outdated
@mark-wiemer mark-wiemer added the status: waiting for author waiting on response from OP or other posters - more information needed label Apr 17, 2026
@mostafaNazari702 mostafaNazari702 force-pushed the fix/spec-reporter-fail-indent branch 2 times, most recently from e83c131 to d5e8737 Compare April 17, 2026 14:05
@mark-wiemer mark-wiemer removed the status: waiting for author waiting on response from OP or other posters - more information needed label Apr 18, 2026
Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test itself looks reasonable and good. Just requesting clarity touchups. 🚀

Comment thread test/integration/fixtures/uncaught/issue-2556.fixture.js Outdated
Comment thread lib/reporters/spec.js Outdated
Comment thread test/integration/uncaught.spec.js Outdated
@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author waiting on response from OP or other posters - more information needed label May 16, 2026
@mostafaNazari702 mostafaNazari702 force-pushed the fix/spec-reporter-fail-indent branch from d5e8737 to 7d1de8d Compare May 16, 2026 20:01
@mostafaNazari702 mostafaNazari702 force-pushed the fix/spec-reporter-fail-indent branch from 7d1de8d to 912292e Compare May 16, 2026 20:29
@mostafaNazari702
Copy link
Copy Markdown
Contributor Author

mostafaNazari702 commented May 16, 2026

@mark-wiemer @JoshuaKGoldberg It would be great if Codecov’s diff results were shown only after all other PR checks have completed, and ideally as the final check in the list. A moment ago, seeing it earlier ( with its preliminary results that almost always say "Your PR lacks latest pushes to the codebase" ) made me think i had missed something in my commits, so i ended up pushing unnecessary "fixes" before all the checks had finished. That's partly on me for not waiting, but....yeah, everything is correct now anyway, i re-corrected my pushed commit.

TLDR: Make Codecov do code differences analysis as last "task" in a PR, last check in a PR, meaning.

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

Labels

status: waiting for author waiting on response from OP or other posters - more information needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug: Inconsistent output indenting issue with timings

3 participants