[test optimization] Report test suite parsing errors#7776
[test optimization] Report test suite parsing errors#7776juan-fernandez wants to merge 5 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.97 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 |
This comment has been minimized.
This comment has been minimized.
BenchmarksBenchmark execution time: 2026-03-18 16:41:36 Comparing candidate commit 79da954 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 232 metrics, 28 unstable metrics. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7776 +/- ##
=======================================
Coverage 80.45% 80.45%
=======================================
Files 748 748
Lines 32411 32411
=======================================
Hits 26076 26076
Misses 6335 6335 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>
|
I'm abandoning this for the moment, as it's risky and the value added is unclear |
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.