[test optimization] Activate test suite span in beforeAll/afterAll hooks in jest#7770
Open
juan-fernandez wants to merge 2 commits intomasterfrom
Open
[test optimization] Activate test suite span in beforeAll/afterAll hooks in jest#7770juan-fernandez wants to merge 2 commits intomasterfrom
jest#7770juan-fernandez wants to merge 2 commits intomasterfrom
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) <noreply@anthropic.com>
Contributor
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
|
anmarchenko
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.