[test optimization] Report test suite parsing errors#7776
[test optimization] Report test suite parsing errors#7776juan-fernandez wants to merge 2 commits intomasterfrom
Conversation
…uites The test suite finish handler defers span.finish() via process.nextTick to give ci:jest:test-suite:error time to publish. In runInBand mode, when the last suite finishes right before session finish, the nextTick callback hasn't run yet and the suite span is not included in the session flush — causing missing test_suite_end events for parse errors. Fix: drain the nextTick queue before publishing session finish by awaiting a nextTick promise. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Overall package sizeSelf size: 4.96 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
|
✨ Fix all issues with BitsAI or with Cursor
|
BenchmarksBenchmark execution time: 2026-03-13 15:15:44 Comparing candidate commit 5aab763 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 234 metrics, 26 unstable metrics. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7776 +/- ##
==========================================
- Coverage 80.43% 80.43% -0.01%
==========================================
Files 741 741
Lines 32173 32182 +9
==========================================
+ Hits 25879 25884 +5
- Misses 6294 6298 +4 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The test_suite_end reporting for parse errors relies on behavior only available in recent jest versions. Gate both tests behind onlyLatestIt to avoid failures on jest@24.8.0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
What does this PR do?
Drains the
process.nextTickqueue before publishing session finish in the jest instrumentation, ensuringtest_suite_endevents are flushed for test files that fail to parse.Motivation
The test suite finish handler defers
span.finish()viaprocess.nextTickto giveci:jest:test-suite:errortime to publish. InrunInBandmode, when the last (or only) suite finishes right before session finish, the nextTick callback hasn't run yet and the suite span is not included in the session flush. This causes missingtest_suite_endevents — most visible with parse error suites where no tests run and there are no other suites to create event loop cycles.Additional Notes
The fix is a single line:
await new Promise(resolve => process.nextTick(resolve))beforetestSessionFinishCh.publish(). This ensures all pending suitespan.finish()callbacks complete before the session flush.Two new integration tests verify the fix:
Full jest integration suite (148 tests) passes.