[test optimization] Activate test suite span in beforeAll/afterAll hooks in jest#7770
Conversation
Makes tracer.scope().active() return the test suite span inside beforeAll and afterAll Jest hooks, so users can set custom tags and create child spans during suite setup/teardown. - Add ci:jest:test-suite:hook:fn diagnostic channel - Wrap beforeAll/afterAll hook functions on hook_start events - Bind the test suite span in the plugin for suite-level hooks - Remove encoder filter that dropped non-lifecycle spans from test session traces, allowing custom spans to reach citestcycle - Add integration test with fixture verifying custom tags and child span parent/trace ID linkage Closes #5677 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7770 +/- ##
==========================================
- Coverage 80.42% 80.41% -0.02%
==========================================
Files 741 741
Lines 32182 32182
==========================================
- Hits 25883 25879 -4
- Misses 6299 6303 +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:
|
|
✨ Fix all issues with BitsAI or with Cursor
|
BenchmarksBenchmark execution time: 2026-03-16 09:19:44 Comparing candidate commit 4a5d93b in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 230 metrics, 30 unstable metrics. |
What does this PR do?
Activates the test suite span inside Jest
beforeAllandafterAllhooks so thattracer.scope().active()returns it instead ofnull. This allows users to set custom tags on the suite span and create child spans during suite setup/teardown.Also removes the citestcycle encoder filter that was dropping non-lifecycle spans from test session traces, so custom spans created in hooks are exported alongside test events.
Motivation
Closes #5677. Users instrumenting setup work (API calls, DB seeding, etc.) in
beforeAllhooks had no trace context —tracer.scope().active()returnednull, making those spans invisible in Datadog.