[test optimization] Detect and warn about new tests with dynamic names#7841
Conversation
Detect tests flagged as "new" whose names contain patterns that are almost certainly runtime-generated (unix timestamps, UUIDs, ISO dates, random localhost ports). Detection runs in the worker via _onAddTest and flows to the main process via two paths: - runInBand: shared newTestsWithDynamicNames Set works directly - parallel workers: _dd.has_dynamic_name span tag travels via worker-report:trace; onMessageWrapper extracts it Consolidate ignored-failures and dynamic-name warnings into a single session-end "Datadog Test Optimization" summary banner. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Overall package sizeSelf size: 5.06 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 #7841 +/- ##
==========================================
- Coverage 80.48% 74.51% -5.98%
==========================================
Files 749 768 +19
Lines 32457 35733 +3276
==========================================
+ Hits 26124 26626 +502
- Misses 6333 9107 +2774 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:
|
BenchmarksBenchmark execution time: 2026-03-30 10:47:19 Comparing candidate commit 879fd82 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 233 metrics, 27 unstable metrics. |
Add a test fixture with a dynamic test name (Date.now() in template literal) and an integration test that verifies: - The _dd.has_dynamic_name tag is set on tests with dynamic names - Non-dynamic new tests do not get the tag - The session-end warning message is logged Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded '_dd.has_dynamic_name' string with a constant defined in packages/dd-trace/src/plugins/util/test.js, consistent with how other test tags (TEST_IS_NEW, TEST_IS_MODIFIED, etc.) are defined. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…me test cases Use TEST_SUITE and TEST_NAME constants instead of literal strings in collectDynamicNamesFromTraces. Add test cases for all four dynamic name patterns: timestamp, localhost port, UUID, and ISO date. Update integration test to verify all four patterns are detected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jest
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 879fd82 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
jestThe dynamic-name-test.js fixture was placed in the default playwright testDir, causing it to be picked up by all existing playwright integration tests and inflating test/suite counts. Moves it to a dedicated playwright-tests-dynamic/ directory and updates the integration test to point TEST_DIR at that directory. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
What does this PR do?
Detect tests flagged as "new" whose names contain patterns that are almost certainly runtime-generated (unix timestamps, UUIDs, ISO dates, random localhost ports).
Consolidate ignored-failures and dynamic-name warnings into a single session-end "Datadog Test Optimization" summary banner.
Motivation
Let the user know about issues with new test detection