dd-trace 5.133.0 → 5.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ci/cypress/support.js +15 -1
  3. package/ci/diagnose.js +4 -4
  4. package/ci/test-annotations.d.ts +5 -0
  5. package/ci/test-annotations.js +5 -0
  6. package/ci/test-optimization-validation/approval-artifacts.js +2 -2
  7. package/ci/test-optimization-validation/approval.js +2 -2
  8. package/ci/test-optimization-validation/artifact-id.js +2 -3
  9. package/ci/test-optimization-validation/ci-package-scripts.js +1 -1
  10. package/ci/test-optimization-validation/cli.js +1 -1
  11. package/ci/test-optimization-validation/command-runner.js +2 -3
  12. package/ci/test-optimization-validation/executable.js +1 -1
  13. package/ci/test-optimization-validation/framework-adapters/cucumber.js +1 -1
  14. package/ci/test-optimization-validation/literal-environment.js +2 -2
  15. package/ci/test-optimization-validation/manifest-scaffold.js +1 -1
  16. package/ci/test-optimization-validation/offline-fixtures.js +1 -1
  17. package/ci/test-optimization-validation/redaction.js +3 -3
  18. package/ci/test-optimization-validation/runner-contract.js +10 -10
  19. package/ci/test-optimization-validation/scenarios/ci-wiring.js +1 -1
  20. package/ci/vitest-no-worker-init-annotations.mjs +4 -0
  21. package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
  22. package/ci/vitest-no-worker-init-runner-setup.mjs +7 -5
  23. package/ci/vitest-no-worker-init-setup.mjs +34 -12
  24. package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
  25. package/ext/exporters.js +1 -0
  26. package/index.d.ts +35 -5
  27. package/loader-hook.mjs +53 -0
  28. package/openfeature/exposure-hook.d.ts +66 -0
  29. package/openfeature/exposure-hook.js +5 -0
  30. package/package.json +23 -20
  31. package/packages/datadog-core/src/storage.js +1 -1
  32. package/packages/datadog-esbuild/index.js +70 -7
  33. package/packages/datadog-instrumentations/index.js +2 -1
  34. package/packages/datadog-instrumentations/src/cucumber.js +64 -21
  35. package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
  36. package/packages/datadog-instrumentations/src/graphql.js +9 -3
  37. package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
  38. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +27 -8
  39. package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
  40. package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
  41. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
  42. package/packages/datadog-instrumentations/src/helpers/register.js +9 -0
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +16 -6
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +10 -0
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
  46. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/jest.js +12 -0
  47. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
  48. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
  49. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/vitest.js +8 -0
  50. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
  51. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +8 -0
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
  53. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +13 -0
  54. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +1 -1
  55. package/packages/datadog-instrumentations/src/jest.js +332 -137
  56. package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
  57. package/packages/datadog-instrumentations/src/mariadb.js +13 -6
  58. package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
  59. package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
  60. package/packages/datadog-instrumentations/src/mocha/utils.js +92 -13
  61. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
  62. package/packages/datadog-instrumentations/src/nova-sonic/session.js +25 -16
  63. package/packages/datadog-instrumentations/src/oracledb.js +33 -0
  64. package/packages/datadog-instrumentations/src/pg.js +2 -1
  65. package/packages/datadog-instrumentations/src/playwright.js +81 -26
  66. package/packages/datadog-instrumentations/src/react-router.js +106 -0
  67. package/packages/datadog-instrumentations/src/stripe.js +23 -12
  68. package/packages/datadog-instrumentations/src/typesafe.js +89 -0
  69. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -47
  70. package/packages/datadog-instrumentations/src/vitest-main.js +33 -3
  71. package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
  72. package/packages/datadog-instrumentations/src/vitest-util.js +5 -2
  73. package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
  74. package/packages/datadog-instrumentations/src/vitest.js +16 -6
  75. package/packages/datadog-plugin-cucumber/src/index.js +5 -0
  76. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +277 -44
  77. package/packages/datadog-plugin-cypress/src/index.js +1 -1
  78. package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
  79. package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
  80. package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
  81. package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
  82. package/packages/datadog-plugin-cypress/src/support.js +1217 -437
  83. package/packages/datadog-plugin-graphql/src/execute.js +2 -2
  84. package/packages/datadog-plugin-graphql/src/utils.js +5 -5
  85. package/packages/datadog-plugin-jest/src/index.js +25 -3
  86. package/packages/datadog-plugin-mocha/src/index.js +47 -6
  87. package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
  88. package/packages/datadog-plugin-playwright/src/index.js +4 -0
  89. package/packages/datadog-plugin-react-router/src/index.js +118 -0
  90. package/packages/datadog-plugin-typesafe/src/index.js +17 -0
  91. package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
  92. package/packages/datadog-plugin-vitest/src/index.js +8 -0
  93. package/packages/dd-trace/src/agent/info.js +2 -1
  94. package/packages/dd-trace/src/aiguard/evaluation.js +143 -1
  95. package/packages/dd-trace/src/aiguard/sdk.js +0 -11
  96. package/packages/dd-trace/src/appsec/iast/path-line.js +2 -1
  97. package/packages/dd-trace/src/appsec/stack_trace.js +3 -2
  98. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +3 -2
  99. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +9 -16
  100. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -2
  101. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +9 -16
  102. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +9 -14
  103. package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
  104. package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
  105. package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
  106. package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
  107. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +9 -16
  108. package/packages/dd-trace/src/config/defaults.js +4 -3
  109. package/packages/dd-trace/src/config/generated-config-types.d.ts +6 -0
  110. package/packages/dd-trace/src/config/index.js +140 -39
  111. package/packages/dd-trace/src/config/parsers.js +9 -1
  112. package/packages/dd-trace/src/config/supported-configurations.json +25 -0
  113. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +6 -5
  114. package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -5
  115. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +4 -6
  116. package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
  117. package/packages/dd-trace/src/debugger/unsupported-runtime.js +16 -0
  118. package/packages/dd-trace/src/encode/0.4.js +2 -2
  119. package/packages/dd-trace/src/esm-module-load.js +58 -0
  120. package/packages/dd-trace/src/exporter.js +25 -6
  121. package/packages/dd-trace/src/exporters/agent/index.js +3 -1
  122. package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
  123. package/packages/dd-trace/src/exporters/common/request.js +4 -4
  124. package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
  125. package/packages/dd-trace/src/exporters/log/index.js +4 -3
  126. package/packages/dd-trace/src/llmobs/agent-manifest.js +19 -2
  127. package/packages/dd-trace/src/llmobs/constants/tags.js +4 -0
  128. package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
  129. package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
  130. package/packages/dd-trace/src/llmobs/index.js +13 -2
  131. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
  132. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
  133. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +8 -4
  134. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +5 -0
  135. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +9 -1
  136. package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
  137. package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
  138. package/packages/dd-trace/src/llmobs/sdk.js +17 -5
  139. package/packages/dd-trace/src/llmobs/span_processor.js +222 -12
  140. package/packages/dd-trace/src/llmobs/tagger.js +21 -8
  141. package/packages/dd-trace/src/llmobs/util.js +10 -4
  142. package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
  143. package/packages/dd-trace/src/log/writer.js +7 -1
  144. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +64 -6
  145. package/packages/dd-trace/src/openfeature/configuration_source.js +18 -2
  146. package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
  147. package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
  148. package/packages/dd-trace/src/openfeature/flagging_provider.js +39 -13
  149. package/packages/dd-trace/src/openfeature/index.js +6 -0
  150. package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
  151. package/packages/dd-trace/src/openfeature/writers/base.js +62 -27
  152. package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
  153. package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
  154. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
  155. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
  156. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
  157. package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
  158. package/packages/dd-trace/src/openfeature/writers/util.js +4 -4
  159. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
  160. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +18 -1
  161. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
  162. package/packages/dd-trace/src/opentracing/tracer.js +9 -13
  163. package/packages/dd-trace/src/otel-thread-ctx.js +47 -21
  164. package/packages/dd-trace/src/plugin_manager.js +1 -2
  165. package/packages/dd-trace/src/plugins/ci_plugin.js +4 -4
  166. package/packages/dd-trace/src/plugins/index.js +3 -0
  167. package/packages/dd-trace/src/plugins/tracing.js +1 -2
  168. package/packages/dd-trace/src/plugins/util/git.js +102 -40
  169. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +2 -4
  170. package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -1
  171. package/packages/dd-trace/src/plugins/util/test.js +28 -6
  172. package/packages/dd-trace/src/plugins/util/web.js +106 -20
  173. package/packages/dd-trace/src/process-tags/index.js +1 -1
  174. package/packages/dd-trace/src/profiling/config.js +6 -3
  175. package/packages/dd-trace/src/proxy.js +15 -4
  176. package/packages/dd-trace/src/serverless.js +3 -2
  177. package/packages/dd-trace/src/span_processor.js +21 -9
  178. package/packages/dd-trace/src/span_stats.js +32 -3
  179. package/packages/dd-trace/src/startup-log.js +2 -1
  180. package/packages/dd-trace/src/tagger.js +7 -5
  181. package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
  182. package/packages/dd-trace/src/telemetry/index.js +3 -0
  183. package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
  184. package/packages/dd-trace/src/telemetry/logs/log-collector.js +2 -1
  185. package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
  186. package/packages/dd-trace/src/util.js +9 -5
  187. package/register.js +2 -1
  188. package/vendor/dist/@apm-js-collab/code-transformer/index.js +8 -8
  189. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  190. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
  191. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
  192. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  193. package/vendor/dist/@opentelemetry/resources/LICENSE +0 -201
  194. package/vendor/dist/@opentelemetry/resources/index.js +0 -1
@@ -14,6 +14,7 @@ const { storage } = require('../../datadog-core')
14
14
  const shimmer = require('../../datadog-shimmer')
15
15
  const { getEnvironmentVariable, getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
16
16
  const log = require('../../dd-trace/src/log')
17
+ const { getTestAnnotations, copyTestAnnotations } = require('../../dd-trace/src/ci-visibility/test-annotations')
17
18
  const {
18
19
  EMPTY_EFD_RETRY_POLICY,
19
20
  getEfdRetryCountForDuration,
@@ -38,7 +39,7 @@ const {
38
39
  getTestEndLine,
39
40
  isModifiedTest,
40
41
  DYNAMIC_NAME_RE,
41
- collectDynamicNamesFromTraces,
42
+ collectTestOptimizationSummariesFromTraces,
42
43
  recordTestManagementExecution,
43
44
  recordAttemptToFixExecution,
44
45
  logAttemptToFixTestExecution,
@@ -64,7 +65,7 @@ const {
64
65
  getChannelPromise,
65
66
  publishWithCompletion,
66
67
  } = require('./helpers/channel')
67
- const { addHook, channel } = require('./helpers/instrument')
68
+ const { addHook, channel, getHooks, tracingChannel } = require('./helpers/instrument')
68
69
 
69
70
  const testSessionStartCh = channel('ci:jest:session:start')
70
71
  const testSessionFinishCh = channel('ci:jest:session:finish')
@@ -125,6 +126,7 @@ const jestSessionState = (globalThis[JEST_SESSION_STATE] ||= {})
125
126
 
126
127
  // https://github.com/jestjs/jest/blob/41f842a46bb2691f828c3a5f27fc1d6290495b82/packages/jest-circus/src/types.ts#L9C8-L9C54
127
128
  const RETRY_TIMES = Symbol.for('RETRY_TIMES')
129
+ const RETRY_TIMES_SETTER = Symbol.for('RETRY_TIMES_SETTER')
128
130
 
129
131
  let skippableSuites = []
130
132
  let skippableSuitesCoverage
@@ -186,15 +188,16 @@ const efdSlowAbortedTests = new Set()
186
188
  const efdCandidates = new Set()
187
189
  // Per-declaration dynamic ATR retry count, retained across attempts of the same Jest test object.
188
190
  const dynamicAtrRetryCountByTest = new Map()
189
- // Jest only accepts a suite-wide retry ceiling. Terminal dynamic failures are
191
+ // Jest only accepts a suite-wide retry ceiling. Excluded and terminal dynamic failures are
190
192
  // temporarily cleared to keep that ceiling from scheduling another retry, then
191
193
  // restored before Jest reports the suite result.
192
- const dynamicAtrFinalErrorsByTest = new Map()
194
+ const terminalRetryErrorsByTest = new Map()
193
195
  // Custom environments may prevent extensions after their base constructor runs.
194
- const dynamicAtrResultHandlerRegistrations = new WeakMap()
196
+ const retryResultHandlerRegistrations = new WeakMap()
195
197
  // Tests that are genuinely new (not in known tests list).
196
198
  const newTests = new Set()
197
199
  const testSuiteJestObjects = new Map()
200
+ const deferredTestSuiteFinishes = new Map()
198
201
  const testSuiteDatadogEnvironments = new Map()
199
202
  const wrappedJestGlobals = new WeakSet()
200
203
  const wrappedJestEsmLoaders = new WeakSet()
@@ -264,6 +267,22 @@ let jestEachBind
264
267
  // Track quarantined tests whose errors were suppressed, keyed by "suite › testName"
265
268
  const quarantinedFailingTests = new Set()
266
269
 
270
+ /**
271
+ * @param {string} suite
272
+ * @param {string} name
273
+ * @param {{ mustFail: boolean, noAutoRetry: boolean }|undefined} annotations
274
+ */
275
+ function getEffectiveManagementProperties (suite, name, annotations) {
276
+ const properties = testManagementTests?.jest?.suites?.[suite]?.tests?.[name]?.properties
277
+ if (!properties || !annotations) return properties
278
+ return {
279
+ ...properties,
280
+ disabled: !annotations.mustFail && properties.disabled,
281
+ quarantined: !annotations.mustFail && properties.quarantined,
282
+ attempt_to_fix: !annotations.noAutoRetry && properties.attempt_to_fix,
283
+ }
284
+ }
285
+
267
286
  function getJestRepositoryRoot (readConfigsResult) {
268
287
  const configuredRepositoryRoot = readConfigsResult.configs
269
288
  ?.find(config => config.testEnvironmentOptions?._ddRepositoryRoot)
@@ -438,9 +457,9 @@ function getAttemptToFixExecutionsFromJestResults (result) {
438
457
  ?.tests
439
458
  if (!testManagementTestsForSuite) continue
440
459
 
441
- for (const { fullName, status } of testResults) {
460
+ for (const { fullName, status, _ddTestAnnotations } of testResults) {
442
461
  const testName = removeSeedSuffixFromTestName(fullName)
443
- const testManagementTest = testManagementTestsForSuite[testName]?.properties
462
+ const testManagementTest = getEffectiveManagementProperties(testSuite, testName, _ddTestAnnotations)
444
463
  if (!testManagementTest?.attempt_to_fix) continue
445
464
  const testStatus = getTestStatusFromJestResult(status) ||
446
465
  (status === 'pending' || status === 'todo' ? 'skip' : undefined)
@@ -486,9 +505,9 @@ function recordTestManagementExecutionsFromJestResults (result, quarantineFailur
486
505
  ?.tests
487
506
  if (!testManagementTestsForSuite) continue
488
507
 
489
- for (const { fullName, status } of testResults) {
508
+ for (const { fullName, status, _ddTestAnnotations } of testResults) {
490
509
  const testName = removeSeedSuffixFromTestName(fullName)
491
- const testManagementTest = testManagementTestsForSuite[testName]?.properties
510
+ const testManagementTest = getEffectiveManagementProperties(testSuite, testName, _ddTestAnnotations)
492
511
  if (!testManagementTest) continue
493
512
 
494
513
  const name = `${testSuite} › ${testName}`
@@ -562,8 +581,8 @@ function setOriginalConcurrentTest (wrappedConcurrentTest, originalConcurrentTes
562
581
  *
563
582
  * @param {{ name: string, test?: { errors: unknown[] } }} event
564
583
  */
565
- function suppressDynamicAtrErrors (event) {
566
- if (event.name === 'test_done' && dynamicAtrFinalErrorsByTest.has(event.test)) {
584
+ function suppressTerminalRetryErrors (event) {
585
+ if (event.name === 'test_done' && terminalRetryErrorsByTest.has(event.test)) {
567
586
  event.test.errors = []
568
587
  }
569
588
  }
@@ -573,13 +592,13 @@ function suppressDynamicAtrErrors (event) {
573
592
  *
574
593
  * @param {{ name: string }} event
575
594
  */
576
- function restoreDynamicAtrErrors (event) {
577
- if (event.name !== 'run_describe_finish' || dynamicAtrFinalErrorsByTest.size === 0) return
595
+ function restoreTerminalRetryErrors (event) {
596
+ if (event.name !== 'run_describe_finish' || terminalRetryErrorsByTest.size === 0) return
578
597
 
579
- for (const [test, errors] of dynamicAtrFinalErrorsByTest) {
598
+ for (const [test, errors] of terminalRetryErrorsByTest) {
580
599
  test.errors = errors
581
600
  }
582
- dynamicAtrFinalErrorsByTest.clear()
601
+ terminalRetryErrorsByTest.clear()
583
602
  }
584
603
 
585
604
  /**
@@ -600,7 +619,7 @@ function getWrappedCustomHandleTestEvent (handleTestEvent, datadogHandleTestEven
600
619
  }
601
620
 
602
621
  const wrappedHandleTestEvent = function (event, state) {
603
- restoreDynamicAtrErrors(event)
622
+ restoreTerminalRetryErrors(event)
604
623
  const result = handleTestEvent.call(this, event, state)
605
624
  const runDatadogHandler = value => {
606
625
  if (isDatadogJestEventHandled(event)) return value
@@ -664,6 +683,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
664
683
 
665
684
  return class DatadogEnvironment extends BaseEnvironment {
666
685
  #activeDetachedEfdRetries
686
+ #boundTestEach = new WeakSet()
687
+ #describeRetryAttempts
667
688
  #detachedEfdRetryConcurrency
668
689
  #detachedEfdRetryQueue
669
690
  #discardedEfdRetryTests
@@ -671,6 +692,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
671
692
  #efdRetryGatesByName
672
693
  #expect
673
694
  #pendingPre30ConcurrentTests
695
+ #registeringConcurrentTestState
696
+ /** @type {Map<object, { finish: (finalStatus?: string) => void, finalStatus: string }>|undefined} */
697
+ #pendingDescribeRetryFinishes
674
698
  /** @type {(() => void)|undefined} */
675
699
  #restoreSnapshotState
676
700
  /** @type {Set<string>|undefined} */
@@ -741,9 +765,13 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
741
765
  }
742
766
  }
743
767
 
768
+ this.hasAutomaticRetries = false
769
+ this.testResultAnnotations = []
770
+ this.hasExplicitRetries = !!this.global[RETRY_TIMES]
744
771
  if (this.isFlakyTestRetriesEnabled) {
745
772
  const currentNumRetries = this.global[RETRY_TIMES]
746
773
  if (!currentNumRetries) {
774
+ this.hasAutomaticRetries = true
747
775
  // When dynamic ATR is enabled, use the max bucket value as the initial count.
748
776
  // The actual duration-based count is computed per test after the first attempt.
749
777
  if (this.isDynamicAtrEnabled) {
@@ -810,9 +838,11 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
810
838
  * Rebuilds serial `test.each` so every generated row function keeps its parameters.
811
839
  *
812
840
  * @param {Function|undefined} test
841
+ * @param {boolean} needsEachError
813
842
  */
814
- bindTestEach (test) {
815
- if (typeof test?.each !== 'function') return
843
+ bindTestEach (test, needsEachError = false) {
844
+ if (typeof test?.each !== 'function' || this.#boundTestEach.has(test)) return
845
+ this.#boundTestEach.add(test)
816
846
 
817
847
  const bind = this.getJestEachBind()
818
848
  if (typeof bind !== 'function') {
@@ -835,6 +865,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
835
865
  const testParameters = getFormattedJestTestParameters(eachArgs)
836
866
  return function (...testArgs) {
837
867
  let parameterIndex = 0
868
+ const sourceTestFn = testArgs[1]
838
869
  const eachTest = function (testName, testFn, ...callArgs) {
839
870
  const parameters = testParameters?.[parameterIndex++]
840
871
  if (parameters !== undefined && typeof testFn === 'function') {
@@ -844,15 +875,26 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
844
875
  getTestParametersString(environment.nameToParams, testName)
845
876
  )
846
877
  }
878
+ copyTestAnnotations(sourceTestFn, testFn)
847
879
  return test.call(this, testName, testFn, ...callArgs)
848
880
  }
849
- const boundTest = bind(eachTest)
881
+ const boundTest = bind(eachTest, !needsEachError, needsEachError)
850
882
  const eachBind = boundTest.apply(this, eachArgs)
851
883
  return eachBind.apply(this, testArgs)
852
884
  }
853
885
  }
854
886
  }
855
887
 
888
+ /** @param {Function|undefined} test */
889
+ bindTestEachGlobals (test) {
890
+ this.bindTestEach(test)
891
+ this.bindTestEach(test?.only)
892
+ this.bindTestEach(test?.skip)
893
+ this.bindTestEach(test?.failing, true)
894
+ this.bindTestEach(test?.only?.failing, true)
895
+ this.bindTestEach(test?.skip?.failing, true)
896
+ }
897
+
856
898
  /**
857
899
  * Wraps Jest's concurrent test registration methods so eager concurrent bodies
858
900
  * in older Jest versions execute inside their test span context.
@@ -917,7 +959,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
917
959
  sourceTestFn: environment.concurrentTestSourceFns.get(testFn),
918
960
  timeout: args[0],
919
961
  })
920
- return concurrentTest.call(this, testName, wrappedTestFn, ...args)
962
+ return environment.registerConcurrentTest(concurrentTest, this, testName, wrappedTestFn, ...args)
921
963
  }
922
964
  })
923
965
 
@@ -927,6 +969,25 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
927
969
  this.bindConcurrentEach(wrappedConcurrentTest, methodName === 'failing')
928
970
  }
929
971
 
972
+ /**
973
+ * Retains declaration identity when older Circus replaces the supplied callback.
974
+ *
975
+ * @param {Function} test
976
+ * @param {unknown} thisArg
977
+ * @param {string} testName
978
+ * @param {Function} testFn
979
+ * @param {...unknown} args
980
+ */
981
+ registerConcurrentTest (test, thisArg, testName, testFn, ...args) {
982
+ const previous = this.#registeringConcurrentTestState
983
+ this.#registeringConcurrentTestState = this.concurrentTestStates.get(testFn)
984
+ try {
985
+ return test.call(thisArg, testName, testFn, ...args)
986
+ } finally {
987
+ this.#registeringConcurrentTestState = previous
988
+ }
989
+ }
990
+
930
991
  /**
931
992
  * Rebuilds a concurrent `.each` helper so each generated row calls the wrapped test function.
932
993
  *
@@ -951,6 +1012,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
951
1012
  environment.appendNameToParams(testName, parameters)
952
1013
  }
953
1014
  if (typeof testFn === 'function' && typeof sourceTestFn === 'function') {
1015
+ copyTestAnnotations(sourceTestFn, testFn)
954
1016
  environment.concurrentTestSourceFns.set(testFn, sourceTestFn)
955
1017
  }
956
1018
  return concurrentTest.call(this, testName, testFn, ...callArgs)
@@ -986,6 +1048,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
986
1048
  const wrappedTestFn = shimmer.wrapFunction(testFn, testFn => function (...args) {
987
1049
  return environment.runConcurrentTestFn(concurrentTestState, testFn, this, args)
988
1050
  })
1051
+ copyTestAnnotations(options?.sourceTestFn || testFn, wrappedTestFn)
989
1052
  this.concurrentTestStates.set(wrappedTestFn, concurrentTestState)
990
1053
  return wrappedTestFn
991
1054
  }
@@ -1032,9 +1095,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1032
1095
  createConcurrentTestContext (testName, testFn, asyncError, state, options) {
1033
1096
  const testFullName = this.getTestNameFromAddTestEvent({ testName }, state)
1034
1097
  const isNewTest = this.isKnownTestsEnabled && !this.knownTestsForThisSuite?.includes(testFullName)
1035
- const isAttemptToFix = this.isTestManagementTestsEnabled &&
1036
- this.testManagementTestsForThisSuite?.attemptToFix?.includes(testFullName)
1037
1098
  const sourceTestFn = options?.sourceTestFn || testFn
1099
+ const policy = this.getTestPolicy(testFullName, sourceTestFn)
1038
1100
  const ctx = {
1039
1101
  name: testFullName,
1040
1102
  suite: this.testSuite,
@@ -1046,11 +1108,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1046
1108
  isEfdRetry: options?.isEfdRetry === true,
1047
1109
  efdRetryGates: options?.efdRetryGates,
1048
1110
  efdRetryIndex: options?.efdRetryIndex,
1049
- isAttemptToFix,
1111
+ ...policy,
1050
1112
  isAttemptToFixRetry: options?.isAttemptToFixRetry === true,
1051
1113
  isJestRetry: false,
1052
- isDisabled: this.testManagementTestsForThisSuite?.disabled?.includes(testFullName),
1053
- isQuarantined: this.testManagementTestsForThisSuite?.quarantined?.includes(testFullName),
1054
1114
  isModified: options?.isModified ?? this.isTestModified(asyncError, sourceTestFn),
1055
1115
  hasDynamicName: isNewTest && DYNAMIC_NAME_RE.test(testFullName),
1056
1116
  testSuiteAbsolutePath: this.testSuiteAbsolutePath,
@@ -1076,7 +1136,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1076
1136
  if (!this.isImpactedTestsEnabled || !asyncError || typeof testFn !== 'function') return false
1077
1137
 
1078
1138
  const testStartLine = getTestLineStart(asyncError, this.testSuite)
1079
- const testEndLine = getTestEndLine(testFn, testStartLine)
1139
+ const testEndLine = getTestEndLine(getTestAnnotations(testFn).source || testFn, testStartLine)
1080
1140
  return isModifiedTest(
1081
1141
  this.testSourceFile,
1082
1142
  testStartLine,
@@ -1544,6 +1604,27 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1544
1604
  }
1545
1605
  }
1546
1606
 
1607
+ /**
1608
+ * @param {string} testName
1609
+ * @param {Function|undefined} testFn
1610
+ */
1611
+ getTestPolicy (testName, testFn) {
1612
+ const { mustFail, noAutoRetry } = getTestAnnotations(testFn)
1613
+ const properties = this.isTestManagementTestsEnabled ? this.testManagementTestsForThisSuite : undefined
1614
+ return {
1615
+ mustFail,
1616
+ noAutoRetry,
1617
+ assignedManagementProperties: {
1618
+ isAttemptToFix: !!properties?.attemptToFix?.includes(testName),
1619
+ isDisabled: !!properties?.disabled?.includes(testName),
1620
+ isQuarantined: !!properties?.quarantined?.includes(testName),
1621
+ },
1622
+ isAttemptToFix: !noAutoRetry && !!properties?.attemptToFix?.includes(testName),
1623
+ isDisabled: !mustFail && !!properties?.disabled?.includes(testName),
1624
+ isQuarantined: !mustFail && !!properties?.quarantined?.includes(testName),
1625
+ }
1626
+ }
1627
+
1547
1628
  // This function returns an array if the known tests are valid and null otherwise.
1548
1629
  getKnownTestsForSuite (suiteKnownTests) {
1549
1630
  // `suiteKnownTests` is `this.testEnvironmentOptions._ddKnownTests`,
@@ -1671,7 +1752,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1671
1752
  timeout,
1672
1753
  }
1673
1754
  )
1674
- test.call(concurrentTestState.concurrentTestThisArg, testName, retryFn, timeout)
1755
+ this.registerConcurrentTest(test, concurrentTestState.concurrentTestThisArg, testName, retryFn, timeout)
1675
1756
  } else if (this.global.test) {
1676
1757
  const test = mode === 'only' ? this.global.test.only : this.global.test
1677
1758
  // The child-count check below proves Jest added a node, so retries can share the test
@@ -1928,9 +2009,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1928
2009
  }
1929
2010
 
1930
2011
  const testFullName = this.getTestNameFromAddTestEvent(event, state)
1931
- const concurrentTestContexts = this.concurrentTestContexts.get(testFullName)
1932
2012
  const concurrentTestState = this.concurrentTestStates.get(event.fn) ||
1933
- concurrentTestContexts?.at(-1)?.concurrentTestState
2013
+ this.#registeringConcurrentTestState
1934
2014
  if (concurrentTestState && registeredTest?.fn === event.fn) {
1935
2015
  testContexts.set(registeredTest, concurrentTestState.ctx)
1936
2016
  }
@@ -1938,10 +2018,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1938
2018
  return
1939
2019
  }
1940
2020
  const isSkipped = event.mode === 'todo' || event.mode === 'skip'
1941
- const isAttemptToFix = this.isTestManagementTestsEnabled &&
1942
- this.testManagementTestsForThisSuite?.attemptToFix?.includes(testFullName)
1943
- const isDisabled = this.isTestManagementTestsEnabled &&
1944
- this.testManagementTestsForThisSuite?.disabled?.includes(testFullName)
2021
+ const { isAttemptToFix, isDisabled, noAutoRetry } = this.getTestPolicy(testFullName, event.fn)
1945
2022
  if (isAttemptToFix && !isSkipped) {
1946
2023
  retriedTestsToNumAttempts.set(testFullName, 0)
1947
2024
  testsToBeRetried.add(testFullName)
@@ -1975,6 +2052,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1975
2052
  }
1976
2053
 
1977
2054
  if (
2055
+ noAutoRetry ||
1978
2056
  isAttemptToFix ||
1979
2057
  isDisabled ||
1980
2058
  isSkipped ||
@@ -2021,21 +2099,24 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2021
2099
  this.handleAddTestEvent(event, state)
2022
2100
  }
2023
2101
 
2024
- restoreDynamicAtrErrors(event)
2102
+ restoreTerminalRetryErrors(event)
2025
2103
 
2026
2104
  if (super.handleTestEvent) {
2027
2105
  await super.handleTestEvent(event, state)
2028
2106
  }
2029
2107
 
2030
2108
  if (event.name === 'run_start') {
2109
+ this.#finishPendingDescribeRetries()
2110
+ this.#describeRetryAttempts = undefined
2031
2111
  this.#trackQuarantinedSnapshots()
2032
- const registerResultHandler = dynamicAtrResultHandlerRegistrations.get(this)
2033
- dynamicAtrResultHandlerRegistrations.delete(this)
2112
+ const registerResultHandler = retryResultHandlerRegistrations.get(this)
2113
+ retryResultHandlerRegistrations.delete(this)
2034
2114
  registerResultHandler?.()
2035
2115
  } else if (event.name === 'setup') {
2036
2116
  this.#expect = event.runtimeGlobals?.expect ?? this.global.expect
2037
2117
  this.wrapConcurrentTest(state)
2038
- this.bindTestEach(this.global.test)
2118
+ this.wrapConcurrentTestGlobals(event.runtimeGlobals?.test, state)
2119
+ this.bindTestEachGlobals(event.runtimeGlobals?.test ?? this.global.test)
2039
2120
  }
2040
2121
  if (
2041
2122
  event.name === 'run_describe_start' &&
@@ -2045,20 +2126,38 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2045
2126
  ) {
2046
2127
  this.preparePre30ConcurrentTests(event.describeBlock, state)
2047
2128
  }
2129
+ if (event.name === 'describe_retry' && this.#describeRetryAttempts) {
2130
+ const block = event.describeBlock
2131
+ this.#describeRetryAttempts.set(block, (this.#describeRetryAttempts.get(block) ?? 0) + 1)
2132
+ // Replaying a parent gives each nested describe a fresh native retry budget.
2133
+ const blocks = [block]
2134
+ while (blocks.length) {
2135
+ for (const child of blocks.pop().children) {
2136
+ if (child.type !== 'describeBlock') continue
2137
+ this.#describeRetryAttempts.delete(child)
2138
+ blocks.push(child)
2139
+ }
2140
+ }
2141
+ }
2048
2142
  if (event.name === 'concurrent_tests_start') {
2049
2143
  this.orderConcurrentEfdRetries(event.tests)
2050
2144
  } else if (event.name === 'test_start') {
2145
+ const pendingFinish = this.#pendingDescribeRetryFinishes?.get(event.test)
2146
+ if (pendingFinish) {
2147
+ this.#pendingDescribeRetryFinishes?.delete(event.test)
2148
+ // An actual replay makes the preceding execution nonterminal.
2149
+ pendingFinish.finish()
2150
+ }
2051
2151
  const testName = getJestTestName(event.test)
2052
- let isAttemptToFix = false
2053
- let isDisabled = false
2054
- let isQuarantined = false
2055
- if (this.isTestManagementTestsEnabled) {
2056
- isAttemptToFix = this.testManagementTestsForThisSuite?.attemptToFix?.includes(testName)
2057
- isDisabled = this.testManagementTestsForThisSuite?.disabled?.includes(testName)
2058
- isQuarantined = this.testManagementTestsForThisSuite?.quarantined?.includes(testName)
2059
- if (!isAttemptToFix && isDisabled) {
2060
- event.test.mode = 'skip'
2061
- }
2152
+ const registeredConcurrentTestState = testContexts.get(event.test)?.concurrentTestState
2153
+ const concurrentTestState = this.concurrentTestStates.get(event.test.fn) ||
2154
+ registeredConcurrentTestState
2155
+ // Older Circus replaces concurrent callbacks after registration to schedule their execution.
2156
+ copyTestAnnotations(concurrentTestState?.testFn, event.test.fn)
2157
+ const { isAttemptToFix, isDisabled, isQuarantined, mustFail, noAutoRetry, assignedManagementProperties } =
2158
+ this.getTestPolicy(testName, event.test.fn)
2159
+ if (!isAttemptToFix && isDisabled) {
2160
+ event.test.mode = 'skip'
2062
2161
  }
2063
2162
  if (
2064
2163
  event.test.mode === 'todo' ||
@@ -2067,13 +2166,10 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2067
2166
  return
2068
2167
  }
2069
2168
 
2070
- const registeredConcurrentTestState = testContexts.get(event.test)?.concurrentTestState
2071
- const concurrentTestState = this.concurrentTestStates.get(event.test.fn) ||
2072
- registeredConcurrentTestState
2073
2169
  let concurrentCtx = concurrentTestState?.ctx
2074
2170
  if (concurrentCtx) {
2075
2171
  this.removeConcurrentTestContext(testName, concurrentCtx)
2076
- } else {
2172
+ } else if (event.test.concurrent) {
2077
2173
  concurrentCtx = this.getNextConcurrentTestContext(testName)
2078
2174
  }
2079
2175
  if (hasConcurrentTestsStartEvent && concurrentCtx?.efdRetryGates) {
@@ -2115,7 +2211,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2115
2211
  isNewTest = newTests.has(testName)
2116
2212
  }
2117
2213
 
2118
- const willRunEfd = this.isEarlyFlakeDetectionEnabled &&
2214
+ const willRunEfd = !noAutoRetry && this.isEarlyFlakeDetectionEnabled &&
2119
2215
  hasEfdRetries(this.#earlyFlakeDetectionRetryPolicy) &&
2120
2216
  (isNewTest || isModified)
2121
2217
  event.test[ATR_RETRY_SUPPRESSION_FLAG] = Boolean(isAttemptToFix || willRunEfd)
@@ -2140,6 +2236,25 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2140
2236
  ctx.isAttemptToFix = isAttemptToFix
2141
2237
  ctx.isAttemptToFixRetry ||= numOfAttemptsToFixRetries > 0
2142
2238
  ctx.isJestRetry = isJestRetry
2239
+ ctx.assignedManagementProperties = assignedManagementProperties
2240
+ ctx.mustFail = mustFail
2241
+ ctx.noAutoRetry = noAutoRetry
2242
+ if (noAutoRetry && state.describeRetryOptions) {
2243
+ ctx.hasDescribeRetryPolicy = false
2244
+ ctx.hasDescribeRetriesRemaining = false
2245
+ for (let block = event.test.parent; block; block = block.parent) {
2246
+ const options = state.describeRetryOptions.get(block)
2247
+ if (!options) continue
2248
+ this.#describeRetryAttempts ??= new WeakMap()
2249
+ ctx.hasDescribeRetryPolicy = true
2250
+ const retryCount = Number.parseInt(options.numRetries, 10) || 0
2251
+ if (retryCount > (this.#describeRetryAttempts.get(block) ?? 0)) {
2252
+ ctx.hasDescribeRetriesRemaining = true
2253
+ break
2254
+ }
2255
+ }
2256
+ }
2257
+ ctx.hadErrorsBeforeExecution = event.test.errors.length > 0
2143
2258
  ctx.isDisabled = isDisabled
2144
2259
  ctx.isQuarantined = isQuarantined
2145
2260
  ctx.isModified = isModified
@@ -2292,7 +2407,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2292
2407
  let isAttemptToFix = false
2293
2408
  const testName = getJestTestName(event.test)
2294
2409
  if (this.isTestManagementTestsEnabled) {
2295
- isAttemptToFix = this.testManagementTestsForThisSuite?.attemptToFix?.includes(testName)
2410
+ isAttemptToFix = retryCtx?.isAttemptToFix === true
2296
2411
  if (isAttemptToFix) {
2297
2412
  if (attemptToFixRetriedTestsStatuses.has(testName)) {
2298
2413
  attemptToFixRetriedTestsStatuses.get(testName).push(status)
@@ -2318,6 +2433,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2318
2433
 
2319
2434
  // The first execution selects how many pre-registered EFD retries remain runnable.
2320
2435
  if (
2436
+ !retryCtx?.noAutoRetry &&
2321
2437
  this.isEarlyFlakeDetectionEnabled &&
2322
2438
  efdCandidates.has(testName) &&
2323
2439
  event.test.invocations === 1 &&
@@ -2330,7 +2446,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2330
2446
  }
2331
2447
 
2332
2448
  const isEfdRetry = retryCtx?.isEfdRetry === true
2333
- if (efdCandidates.has(testName)) {
2449
+ if (!retryCtx?.noAutoRetry && efdCandidates.has(testName)) {
2334
2450
  let testStatuses = efdTestStatuses.get(testName)
2335
2451
  if (testStatuses) {
2336
2452
  testStatuses.push(status)
@@ -2346,7 +2462,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2346
2462
  }
2347
2463
 
2348
2464
  // ATR: set failedAllTests when all auto test retries were exhausted and every attempt failed
2349
- if (this.isFlakyTestRetriesEnabled && !isAttemptToFix && !isEfdRetry) {
2465
+ if (this.isFlakyTestRetriesEnabled && !retryCtx?.noAutoRetry && !isAttemptToFix && !isEfdRetry) {
2350
2466
  // Dynamic ATR: after the first attempt, compute the duration-based retry budget.
2351
2467
  if (
2352
2468
  this.isDynamicAtrEnabled &&
@@ -2374,14 +2490,18 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2374
2490
  const numRetries = this.global[RETRY_TIMES]
2375
2491
  const numTestExecutions = event.test?.invocations
2376
2492
  // Dynamic ATR: use the per-test duration-based count instead of the global flat limit.
2377
- const dynamicAtrCount = this.isDynamicAtrEnabled && dynamicAtrRetryCountByTest.has(event.test)
2378
- ? dynamicAtrRetryCountByTest.get(event.test)
2379
- : undefined
2493
+ const suppressAutomaticRetries = retryCtx?.noAutoRetry && !this.hasExplicitRetries
2494
+ const dynamicAtrCount = suppressAutomaticRetries
2495
+ ? 0
2496
+ : this.isDynamicAtrEnabled && !retryCtx?.noAutoRetry && dynamicAtrRetryCountByTest.has(event.test)
2497
+ ? dynamicAtrRetryCountByTest.get(event.test)
2498
+ : undefined
2380
2499
  const effectiveMaxRetries = dynamicAtrCount === undefined ? numRetries : dynamicAtrCount
2381
2500
  const willBeRetriedByAutoTestRetry = effectiveMaxRetries > 0 && numTestExecutions - 1 < effectiveMaxRetries
2382
2501
  const isFailedTestReplayAllowed = !this.hasConcurrentTests
2383
2502
  const willBeRetriedByFailedTestReplay = isFailedTestReplayAllowed && willBeRetriedByAutoTestRetry
2384
- const mightHitBreakpoint = this.isDiEnabled && isFailedTestReplayAllowed && numTestExecutions >= 2
2503
+ const mightHitBreakpoint = !retryCtx?.noAutoRetry && this.isDiEnabled &&
2504
+ isFailedTestReplayAllowed && numTestExecutions >= 2
2385
2505
 
2386
2506
  // For quarantined tests, track failures so the session can be marked as passing later,
2387
2507
  // and suppress errors so Jest does not mark the test suite as failing.
@@ -2397,8 +2517,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2397
2517
  this.ignoreQuarantinedSnapshotResults(event.test)
2398
2518
 
2399
2519
  // Quarantine must consume terminal failures before we save errors for Jest's final result.
2400
- if (dynamicAtrCount !== undefined && failedAllTests && event.test.errors?.length) {
2401
- dynamicAtrFinalErrorsByTest.set(event.test, event.test.errors)
2520
+ const isTerminalFailure = (dynamicAtrCount !== undefined && failedAllTests) || suppressAutomaticRetries
2521
+ if (isTerminalFailure && event.test.errors?.length) {
2522
+ terminalRetryErrorsByTest.set(event.test, event.test.errors)
2402
2523
  }
2403
2524
 
2404
2525
  const ctx = testContexts.get(event.test)
@@ -2427,7 +2548,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2427
2548
  isEfdRetry,
2428
2549
  isAttemptToFix,
2429
2550
  numTestExecutions,
2430
- dynamicAtrCount)
2551
+ dynamicAtrCount,
2552
+ ctx)
2431
2553
 
2432
2554
  if (status === 'fail') {
2433
2555
  const shouldSetProbe = this.isDiEnabled && willBeRetriedByFailedTestReplay && numTestExecutions === 1
@@ -2445,13 +2567,28 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2445
2567
  }
2446
2568
 
2447
2569
  let isAtrRetry = false
2448
- if (this.isFlakyTestRetriesEnabled && event.test?.invocations > 1 && !isAttemptToFix && !isEfdRetry) {
2570
+ let hasAutomaticRetries = this.hasAutomaticRetries || dynamicAtrRetryCountByTest.has(event.test)
2571
+ // Describe retries suppress per-test retries throughout the block, including nested describes.
2572
+ for (let block = event.test.parent; block; block = block.parent) {
2573
+ if (state.describeRetryOptions?.has(block)) {
2574
+ hasAutomaticRetries = false
2575
+ break
2576
+ }
2577
+ }
2578
+ if (this.isFlakyTestRetriesEnabled && !ctx.noAutoRetry && hasAutomaticRetries &&
2579
+ event.test?.invocations > 1 && !isAttemptToFix && !isEfdRetry) {
2449
2580
  isAtrRetry = true
2450
2581
  }
2451
2582
 
2583
+ /** @type {{ finish?: (finalStatus?: string) => void }|undefined} */
2584
+ const deferredFinish = ctx.noAutoRetry &&
2585
+ ctx.hasDescribeRetriesRemaining && !finalStatus
2586
+ ? {}
2587
+ : undefined
2452
2588
  testFinishCh.publish({
2453
2589
  ...ctx.currentStore,
2454
2590
  status,
2591
+ deferredFinish,
2455
2592
  testStartLine: getTestLineStart(event.test.asyncError, this.testSuite),
2456
2593
  attemptToFixPassed,
2457
2594
  failedAllTests,
@@ -2461,6 +2598,13 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2461
2598
  earlyFlakeAbortReason: efdSlowAbortedTests.has(testName) ? 'slow' : undefined,
2462
2599
  promises,
2463
2600
  })
2601
+ if (deferredFinish?.finish) {
2602
+ this.#pendingDescribeRetryFinishes ??= new Map()
2603
+ this.#pendingDescribeRetryFinishes.set(event.test, {
2604
+ finish: deferredFinish.finish,
2605
+ finalStatus: ctx.isQuarantined ? 'skip' : status,
2606
+ })
2607
+ }
2464
2608
 
2465
2609
  if (promises.hitBreakpointPromise) {
2466
2610
  await promises.hitBreakpointPromise
@@ -2472,9 +2616,29 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2472
2616
  ctx.currentStore = undefined
2473
2617
  }
2474
2618
  } else if (event.name === 'run_finish') {
2619
+ this.#finishPendingDescribeRetries()
2475
2620
  this.#restoreSnapshotState?.()
2476
2621
  this.#restoreSnapshotState = undefined
2477
2622
  this.removeDiscardedEfdRetries()
2623
+ // Mirror Circus result ordering, including skipped tests and generated retry entries.
2624
+ const entries = [state.rootDescribeBlock]
2625
+ this.testResultAnnotations = []
2626
+ const appendAnnotations = test => {
2627
+ const { mustFail, noAutoRetry } = getTestAnnotations(test.fn)
2628
+ this.testResultAnnotations.push({ mustFail, noAutoRetry })
2629
+ }
2630
+ while (entries.length) {
2631
+ const entry = entries.pop()
2632
+ if (hasTestsInChildren && entry.type === 'test') {
2633
+ appendAnnotations(entry)
2634
+ } else {
2635
+ // Jest 24/25 report a describe block's own tests before its nested blocks.
2636
+ if (!hasTestsInChildren) {
2637
+ for (const test of entry.tests) appendAnnotations(test)
2638
+ }
2639
+ for (let index = entry.children.length - 1; index >= 0; index--) entries.push(entry.children[index])
2640
+ }
2641
+ }
2478
2642
  for (const [test, errors] of atrSuppressedErrors) {
2479
2643
  // Do not restore errors for non-ATF quarantined tests — they should stay suppressed
2480
2644
  // so Jest doesn't see the failure (prevents --bail from stopping the run).
@@ -2522,8 +2686,10 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2522
2686
  } else {
2523
2687
  this.discardEfdRetries(testName, event.test)
2524
2688
  }
2689
+ const policy = this.getTestPolicy(testName, event.test.fn)
2525
2690
  testSkippedCh.publish({
2526
2691
  test: {
2692
+ ...policy,
2527
2693
  name: testName,
2528
2694
  suite: this.testSuite,
2529
2695
  testSourceFile: this.testSourceFile,
@@ -2531,7 +2697,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2531
2697
  frameworkVersion: jestVersion,
2532
2698
  testStartLine: getTestLineStart(event.test.asyncError, this.testSuite),
2533
2699
  },
2534
- isDisabled: this.testManagementTestsForThisSuite?.disabled?.includes(testName),
2700
+ isDisabled: policy.isDisabled,
2535
2701
  })
2536
2702
  }
2537
2703
  }
@@ -2595,8 +2761,18 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2595
2761
  isEfdRetry,
2596
2762
  isAttemptToFix,
2597
2763
  numberOfTestInvocations,
2598
- dynamicAtrRetryCount
2764
+ dynamicAtrRetryCount,
2765
+ ctx
2599
2766
  ) {
2767
+ if (ctx.noAutoRetry) {
2768
+ // A sibling failure can replay every test, including passing and quarantined callbacks.
2769
+ if (ctx.hasDescribeRetriesRemaining) return
2770
+ const retryCount = this.hasExplicitRetries ? Number(this.global[RETRY_TIMES]) : 0
2771
+ const hasPendingTestRetry = !ctx.hasDescribeRetryPolicy &&
2772
+ !ctx.hadErrorsBeforeExecution && numberOfTestInvocations <= retryCount
2773
+ if (status === 'fail' && hasPendingTestRetry) return
2774
+ return ctx.isQuarantined ? 'skip' : status
2775
+ }
2600
2776
  const numberOfExecutedRetries = retriedTestsToNumAttempts.get(testName) ?? 0
2601
2777
 
2602
2778
  const efdResult = this.getEfdResult({
@@ -2634,15 +2810,22 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2634
2810
  // If the test is quarantined, regardless of its actual execution result,
2635
2811
  // the final status of its last execution should be reported as 'skip'.
2636
2812
  if (!attemptToFixResult.isAttemptToFixEnabled &&
2637
- this.isTestManagementTestsEnabled &&
2638
- this.testManagementTestsForThisSuite?.quarantined?.includes(testName)) {
2813
+ ctx.isQuarantined) {
2639
2814
  return 'skip'
2640
2815
  }
2641
2816
 
2642
2817
  return efdResult.finalStatus || attemptToFixResult.finalStatus || atrResult.finalStatus
2643
2818
  }
2644
2819
 
2820
+ #finishPendingDescribeRetries () {
2821
+ const pendingFinishes = this.#pendingDescribeRetryFinishes
2822
+ if (!pendingFinishes) return
2823
+ this.#pendingDescribeRetryFinishes = undefined
2824
+ for (const { finish, finalStatus } of pendingFinishes.values()) finish(finalStatus)
2825
+ }
2826
+
2645
2827
  teardown () {
2828
+ this.#finishPendingDescribeRetries()
2646
2829
  this.#restoreSnapshotState?.()
2647
2830
  this.#restoreSnapshotState = undefined
2648
2831
  if (this._globalProxy?.propertyToValue) {
@@ -2652,19 +2835,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2652
2835
  }
2653
2836
  }
2654
2837
  }
2655
- const clearActiveTestSuite = () => {
2656
- realSetTimeout(() => {
2657
- if (activeTestSuiteAbsolutePath === this.testSuiteAbsolutePath) {
2658
- activeTestSuiteAbsolutePath = undefined
2659
- }
2660
- }, 0)
2661
- }
2662
- const result = super.teardown()
2663
- if (result?.then) {
2664
- return result.finally(clearActiveTestSuite)
2665
- }
2666
- clearActiveTestSuite()
2667
- return result
2838
+ return super.teardown()
2668
2839
  }
2669
2840
  }
2670
2841
  }
@@ -3107,7 +3278,9 @@ function searchSourceWrapper (searchSourcePackage, frameworkVersion) {
3107
3278
  getIsFaultyEarlyFlakeDetection(projectSuites, knownTests.jest, earlyFlakeDetectionFaultyThreshold)
3108
3279
 
3109
3280
  if (isFaulty) {
3110
- log.error('Early flake detection is disabled because the number of new suites is too high.')
3281
+ log.warn(knownTests?.jest
3282
+ ? 'Early flake detection is disabled because the number of new suites is too high.'
3283
+ : 'Early flake detection is disabled because the known tests response does not contain Jest tests.')
3111
3284
  isEarlyFlakeDetectionEnabled = false
3112
3285
  isKnownTestsEnabled = false
3113
3286
  const testEnvironmentOptions = testPaths.tests[0]?.context?.config?.testEnvironmentOptions
@@ -3355,26 +3528,21 @@ function getCliWrapper (isNewJestVersion) {
3355
3528
  const failedTests = result
3356
3529
  .results
3357
3530
  .testResults.flatMap(({ testResults, testFilePath: testSuiteAbsolutePath }) => (
3358
- testResults.map(({ fullName: testName, status }) => (
3531
+ testResults.map(({ fullName: testName, status, _ddTestAnnotations }) => (
3359
3532
  {
3360
3533
  // Strip seed suffix so the name matches what was reported via TEST_NAME.
3361
3534
  testName: removeSeedSuffixFromTestName(testName),
3362
3535
  testSuiteAbsolutePath,
3363
3536
  status,
3537
+ _ddTestAnnotations,
3364
3538
  }
3365
3539
  ))
3366
3540
  ))
3367
3541
  .filter(({ status }) => status === 'failed')
3368
3542
 
3369
- for (const { testName, testSuiteAbsolutePath } of failedTests) {
3543
+ for (const { testName, testSuiteAbsolutePath, _ddTestAnnotations } of failedTests) {
3370
3544
  const testSuite = getTestSuitePath(testSuiteAbsolutePath, result.globalConfig.rootDir)
3371
- const testManagementTest = testManagementTests
3372
- ?.jest
3373
- ?.suites
3374
- ?.[testSuite]
3375
- ?.tests
3376
- ?.[testName]
3377
- ?.properties
3545
+ const testManagementTest = getEffectiveManagementProperties(testSuite, testName, _ddTestAnnotations)
3378
3546
  if (testManagementTest?.quarantined && !testManagementTest?.attempt_to_fix) {
3379
3547
  numFailedQuarantinedTests++
3380
3548
  quarantineIgnoredNames.push(`${testSuite} › ${testName}`)
@@ -3492,22 +3660,48 @@ function shouldWaitForTestSuiteFinish (environment) {
3492
3660
  return isJestWorker && environment.globalConfig?.workerIdleMemoryLimit !== undefined
3493
3661
  }
3494
3662
 
3663
+ /**
3664
+ * @param {string} testSuiteAbsolutePath
3665
+ */
3666
+ function finishTestSuiteAfterRun (testSuiteAbsolutePath) {
3667
+ const clearActiveTestSuite = () => {
3668
+ realSetTimeout(() => {
3669
+ if (activeTestSuiteAbsolutePath === testSuiteAbsolutePath) {
3670
+ activeTestSuiteAbsolutePath = undefined
3671
+ }
3672
+ }, 0)
3673
+ }
3674
+ const payload = deferredTestSuiteFinishes.get(testSuiteAbsolutePath)
3675
+ deferredTestSuiteFinishes.delete(testSuiteAbsolutePath)
3676
+ if (payload) {
3677
+ return getChannelPromise(testSuiteFinishCh, { ...payload, waitForFinish: true })
3678
+ .finally(clearActiveTestSuite)
3679
+ }
3680
+ return clearActiveTestSuite()
3681
+ }
3682
+
3683
+ tracingChannel('orchestrion:jest-runner:runTestInternal').end.subscribe((message) => {
3684
+ const ctx = /** @type {{ arguments: [string, ...unknown[]], result: Promise<unknown> }} */ (message)
3685
+ const [testSuiteAbsolutePath] = ctx.arguments
3686
+ // Jest's runner awaits the complete custom teardown before this promise settles.
3687
+ ctx.result = ctx.result.finally(() => finishTestSuiteAfterRun(testSuiteAbsolutePath))
3688
+ })
3689
+
3690
+ for (const hook of getHooks('jest-runner').values()) addHook(hook, moduleExports => moduleExports)
3691
+
3495
3692
  /**
3496
3693
  * @param {Record<string, unknown>} payload
3497
- * @param {boolean} waitForFinish
3694
+ * @param {InstanceType<ReturnType<typeof getWrappedEnvironment>>} environment
3498
3695
  */
3499
- function publishTestSuiteFinish (payload, waitForFinish) {
3696
+ function publishTestSuiteFinish (payload, environment) {
3500
3697
  if (!testSuiteFinishCh.hasSubscribers) return
3501
3698
 
3502
- if (!waitForFinish) {
3503
- testSuiteFinishCh.publish(payload)
3699
+ if (shouldWaitForTestSuiteFinish(environment)) {
3700
+ deferredTestSuiteFinishes.set(environment.testSuiteAbsolutePath, payload)
3504
3701
  return
3505
3702
  }
3506
3703
 
3507
- return getChannelPromise(testSuiteFinishCh, {
3508
- ...payload,
3509
- waitForFinish,
3510
- })
3704
+ testSuiteFinishCh.publish(payload)
3511
3705
  }
3512
3706
 
3513
3707
  function cleanupTestSuiteState (testSuiteAbsolutePath) {
@@ -3632,14 +3826,14 @@ function jestAdapterWrapper (jestAdapter, jestVersion, isIitm, hookMeta) {
3632
3826
 
3633
3827
  wrapEnvironmentCustomHandleTestEvent(environment)
3634
3828
 
3635
- if (environment.isDynamicAtrEnabled && environment.isFlakyTestRetriesEnabled) {
3829
+ if (environment.isFlakyTestRetriesEnabled) {
3636
3830
  // Register at run_start, after Circus installs its per-test reporter and snapshot handlers.
3637
- dynamicAtrResultHandlerRegistrations.set(environment, () => {
3831
+ retryResultHandlerRegistrations.set(environment, () => {
3638
3832
  if (satisfies(jestVersion, '>=30.0.0')) {
3639
- environment.global[Symbol.for('EVENT_HANDLERS')].push(suppressDynamicAtrErrors)
3833
+ environment.global[Symbol.for('EVENT_HANDLERS')].push(suppressTerminalRetryErrors)
3640
3834
  } else {
3641
3835
  const circusState = args[3].requireInternalModule(path.join(hookMeta.moduleBaseDir, 'build/state.js'))
3642
- circusState.addEventHandler(suppressDynamicAtrErrors)
3836
+ circusState.addEventHandler(suppressTerminalRetryErrors)
3643
3837
  }
3644
3838
  })
3645
3839
  }
@@ -3653,6 +3847,9 @@ function jestAdapterWrapper (jestAdapter, jestVersion, isIitm, hookMeta) {
3653
3847
  testSuiteAbsolutePath: environment.testSuiteAbsolutePath,
3654
3848
  })
3655
3849
  return adapter.apply(this, args).then(suiteResults => {
3850
+ for (const [index, result] of suiteResults.testResults.entries()) {
3851
+ result._ddTestAnnotations = environment.testResultAnnotations?.[index]
3852
+ }
3656
3853
  const { numFailingTests, skipped, failureMessage: errorMessage } = suiteResults
3657
3854
  let status = 'pass'
3658
3855
  if (skipped) {
@@ -3684,48 +3881,24 @@ function jestAdapterWrapper (jestAdapter, jestVersion, isIitm, hookMeta) {
3684
3881
  testSuiteAbsolutePath: environment.testSuiteAbsolutePath,
3685
3882
  })
3686
3883
  }
3687
- const waitForFinish = shouldWaitForTestSuiteFinish(environment)
3688
3884
  const finishPayload = {
3689
3885
  status,
3690
3886
  errorMessage,
3691
3887
  testSuiteAbsolutePath: environment.testSuiteAbsolutePath,
3692
3888
  }
3693
- if (waitForFinish) {
3694
- const finishPromise = publishTestSuiteFinish(finishPayload, waitForFinish)
3695
- if (finishPromise) {
3696
- return finishPromise.then(() => {
3697
- // Cleanup per-suite state to avoid memory leaks
3698
- cleanupTestSuiteState(environment.testSuiteAbsolutePath)
3699
-
3700
- return suiteResults
3701
- })
3702
- }
3703
- }
3704
- publishTestSuiteFinish(finishPayload, waitForFinish)
3889
+ publishTestSuiteFinish(finishPayload, environment)
3705
3890
 
3706
3891
  // Cleanup per-suite state to avoid memory leaks
3707
3892
  cleanupTestSuiteState(environment.testSuiteAbsolutePath)
3708
3893
 
3709
3894
  return suiteResults
3710
3895
  }).catch(error => {
3711
- const waitForFinish = shouldWaitForTestSuiteFinish(environment)
3712
3896
  const finishPayload = {
3713
3897
  status: 'fail',
3714
3898
  error,
3715
3899
  testSuiteAbsolutePath: environment.testSuiteAbsolutePath,
3716
3900
  }
3717
- if (waitForFinish) {
3718
- const finishPromise = publishTestSuiteFinish(finishPayload, waitForFinish)
3719
- if (finishPromise) {
3720
- return finishPromise.then(() => {
3721
- // Cleanup per-suite state to avoid memory leaks
3722
- cleanupTestSuiteState(environment.testSuiteAbsolutePath)
3723
-
3724
- throw error
3725
- })
3726
- }
3727
- }
3728
- publishTestSuiteFinish(finishPayload, waitForFinish)
3901
+ publishTestSuiteFinish(finishPayload, environment)
3729
3902
 
3730
3903
  // Cleanup per-suite state to avoid memory leaks
3731
3904
  cleanupTestSuiteState(environment.testSuiteAbsolutePath)
@@ -3978,12 +4151,11 @@ const LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE = new Set([
3978
4151
  'selenium-webdriver/chromium',
3979
4152
  ])
3980
4153
 
3981
- function recordMockedFile (suiteFilePath, moduleName) {
4154
+ function recordMockedFile (suiteFilePath, moduleName, from = suiteFilePath) {
3982
4155
  if (!suiteFilePath || typeof moduleName !== 'string') return
3983
4156
 
3984
4157
  const existingMockedFiles = testSuiteMockedFiles.get(suiteFilePath) || []
3985
- const suiteDir = path.dirname(suiteFilePath)
3986
- const mockPath = path.resolve(suiteDir, moduleName)
4158
+ const mockPath = path.resolve(path.dirname(from), moduleName)
3987
4159
  existingMockedFiles.push(mockPath)
3988
4160
  testSuiteMockedFiles.set(suiteFilePath, existingMockedFiles)
3989
4161
  }
@@ -4018,14 +4190,27 @@ function getMockedFiles (suiteFilePath) {
4018
4190
  return staticMockedFiles
4019
4191
  }
4020
4192
 
4021
- function wrapJestObject (jestObject, suiteFilePath) {
4193
+ function wrapJestObject (jestObject, suiteFilePath, from = suiteFilePath) {
4022
4194
  if (!jestObject || !suiteFilePath || wrappedJestObjects.has(jestObject)) return
4023
4195
 
4024
4196
  testSuiteJestObjects.set(suiteFilePath, jestObject)
4025
4197
  wrappedJestObjects.add(jestObject)
4026
4198
 
4199
+ // retryTimes is created per runtime, so wrap the returned public API object.
4200
+ shimmer.wrap(jestObject, 'retryTimes', retryTimes => function () {
4201
+ const environment = testSuiteDatadogEnvironments.get(suiteFilePath)
4202
+ const setsDescribeRetries = arguments[1]?.entireDescribe &&
4203
+ typeof environment?.global[RETRY_TIMES_SETTER] === 'function'
4204
+ // Older Jest versions ignore entireDescribe and still replace the global budget.
4205
+ if (environment && !setsDescribeRetries) {
4206
+ environment.hasExplicitRetries = true
4207
+ environment.hasAutomaticRetries = false
4208
+ }
4209
+ return retryTimes.apply(this, arguments)
4210
+ })
4211
+
4027
4212
  shimmer.wrap(jestObject, 'mock', mock => function (moduleName) {
4028
- recordMockedFile(suiteFilePath, moduleName)
4213
+ recordMockedFile(suiteFilePath, moduleName, from)
4029
4214
  return mock.apply(this, arguments)
4030
4215
  })
4031
4216
  }
@@ -4039,13 +4224,14 @@ function wrapJestGlobalsForRuntime (runtime) {
4039
4224
  wrappedJestGlobals.add(jestGlobals)
4040
4225
  shimmer.wrap(jestGlobals, 'jestObjectFor', jestObjectFor => function (from) {
4041
4226
  const jestObject = jestObjectFor.apply(this, arguments)
4042
- wrapJestObject(jestObject, from)
4227
+ wrapJestObject(jestObject, runtime._testPath || from, from)
4043
4228
  return jestObject
4044
4229
  })
4045
4230
  }
4046
4231
 
4047
4232
  function wrapConcurrentJestGlobalsForRuntime (runtime, jestGlobals) {
4048
4233
  const environment = testSuiteDatadogEnvironments.get(runtime?._testPath)
4234
+ environment?.bindTestEachGlobals(jestGlobals?.test)
4049
4235
  environment?.wrapConcurrentTestGlobals(jestGlobals?.test, environment.concurrentTestState)
4050
4236
  }
4051
4237
 
@@ -4331,12 +4517,21 @@ addHook({
4331
4517
  }, (runtimePackage) => {
4332
4518
  const Runtime = runtimePackage.default ?? runtimePackage
4333
4519
 
4520
+ // Older Jest versions build the ESM @jest/globals module from this runtime getter.
4521
+ if (typeof Runtime.prototype.getGlobalsFromEnvironment === 'function') {
4522
+ shimmer.wrap(Runtime.prototype, 'getGlobalsFromEnvironment', getGlobals => function () {
4523
+ const globals = getGlobals.apply(this, arguments)
4524
+ wrapConcurrentJestGlobalsForRuntime(this, globals)
4525
+ return globals
4526
+ })
4527
+ }
4528
+
4334
4529
  if (typeof Runtime.prototype._createJestObjectFor === 'function') {
4335
4530
  shimmer.wrap(Runtime.prototype, '_createJestObjectFor', _createJestObjectFor => function (from) {
4336
4531
  const result = _createJestObjectFor.apply(this, arguments)
4337
- const suiteFilePath = this._testPath || from
4532
+ const suiteFilePath = this._testPath || this._environment?.testSuiteAbsolutePath || from
4338
4533
 
4339
- wrapJestObject(result, suiteFilePath)
4534
+ wrapJestObject(result, suiteFilePath, from)
4340
4535
  return result
4341
4536
  })
4342
4537
  }
@@ -4452,7 +4647,7 @@ function onMessageWrapper (onMessage) {
4452
4647
 
4453
4648
  const [code, data] = response
4454
4649
  if (code === JEST_WORKER_TRACE_PAYLOAD_CODE) { // datadog trace payload
4455
- collectDynamicNamesFromTraces(data, newTestsWithDynamicNames)
4650
+ collectTestOptimizationSummariesFromTraces(data, { newTestsWithDynamicNames })
4456
4651
  workerReportTraceCh.publish(data)
4457
4652
  return
4458
4653
  }