dd-trace 6.23.0 → 6.25.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 (353) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ci/cypress/support.js +15 -1
  3. package/ci/init.js +2 -22
  4. package/ci/test-annotations.d.ts +5 -0
  5. package/ci/test-annotations.js +5 -0
  6. package/ci/vitest-no-worker-init-annotations.mjs +4 -0
  7. package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
  8. package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
  9. package/ci/vitest-no-worker-init-setup.mjs +34 -12
  10. package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
  11. package/ext/exporters.js +1 -1
  12. package/index.d.ts +124 -5
  13. package/initialize.mjs +5 -2
  14. package/lambda.d.ts +39 -0
  15. package/lambda.js +3 -0
  16. package/loader-hook.mjs +53 -0
  17. package/openfeature/exposure-hook.d.ts +66 -0
  18. package/openfeature/exposure-hook.js +5 -0
  19. package/package.json +19 -15
  20. package/packages/datadog-core/src/storage.js +1 -1
  21. package/packages/datadog-esbuild/index.js +78 -62
  22. package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
  23. package/packages/datadog-instrumentations/src/cucumber.js +56 -19
  24. package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
  25. package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
  26. package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
  27. package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
  28. package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
  29. package/packages/datadog-instrumentations/src/graphql.js +29 -20
  30. package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
  31. package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
  32. package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
  33. package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
  34. package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
  35. package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
  36. package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
  37. package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
  38. package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
  39. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
  40. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
  41. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
  42. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
  46. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
  47. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
  48. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
  49. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -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 +58 -0
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
  53. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
  54. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
  55. package/packages/datadog-instrumentations/src/ioredis.js +101 -3
  56. package/packages/datadog-instrumentations/src/jest.js +265 -82
  57. package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
  58. package/packages/datadog-instrumentations/src/mariadb.js +13 -6
  59. package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
  60. package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
  61. package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
  62. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
  63. package/packages/datadog-instrumentations/src/next.js +19 -6
  64. package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
  65. package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
  66. package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
  67. package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
  68. package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
  69. package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
  70. package/packages/datadog-instrumentations/src/oracledb.js +33 -0
  71. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
  72. package/packages/datadog-instrumentations/src/pg.js +2 -1
  73. package/packages/datadog-instrumentations/src/playwright.js +81 -28
  74. package/packages/datadog-instrumentations/src/react-router.js +106 -0
  75. package/packages/datadog-instrumentations/src/typesafe.js +89 -0
  76. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
  77. package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
  78. package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
  79. package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
  80. package/packages/datadog-instrumentations/src/vitest.js +10 -8
  81. package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
  82. package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
  83. package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
  84. package/packages/datadog-plugin-cucumber/src/index.js +5 -0
  85. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
  86. package/packages/datadog-plugin-cypress/src/index.js +1 -1
  87. package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
  88. package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
  89. package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
  90. package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
  91. package/packages/datadog-plugin-cypress/src/support.js +1217 -439
  92. package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
  93. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
  94. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
  95. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
  96. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
  97. package/packages/datadog-plugin-graphql/src/execute.js +2 -2
  98. package/packages/datadog-plugin-graphql/src/utils.js +5 -5
  99. package/packages/datadog-plugin-http/src/client.js +32 -9
  100. package/packages/datadog-plugin-http2/src/client.js +38 -13
  101. package/packages/datadog-plugin-jest/src/index.js +25 -3
  102. package/packages/datadog-plugin-mocha/src/index.js +47 -6
  103. package/packages/datadog-plugin-next/src/index.js +112 -14
  104. package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
  105. package/packages/datadog-plugin-playwright/src/index.js +4 -0
  106. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
  107. package/packages/datadog-plugin-react-router/src/index.js +118 -0
  108. package/packages/datadog-plugin-trpc/src/index.js +15 -0
  109. package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
  110. package/packages/datadog-plugin-trpc/src/request.js +81 -0
  111. package/packages/datadog-plugin-typesafe/src/index.js +17 -0
  112. package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
  113. package/packages/datadog-plugin-undici/src/index.js +22 -7
  114. package/packages/datadog-plugin-vitest/src/index.js +8 -0
  115. package/packages/datadog-turbopack/index.js +4 -28
  116. package/packages/datadog-turbopack/src/loader.js +14 -452
  117. package/packages/datadog-webpack/index.js +3 -55
  118. package/packages/dd-trace/src/agent/info.js +2 -1
  119. package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
  120. package/packages/dd-trace/src/aiguard/sdk.js +8 -13
  121. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  122. package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
  123. package/packages/dd-trace/src/appsec/graphql.js +91 -6
  124. package/packages/dd-trace/src/appsec/recommended.json +1287 -90
  125. package/packages/dd-trace/src/before-exit.js +32 -0
  126. package/packages/dd-trace/src/bootstrap.js +5 -3
  127. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
  128. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
  129. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
  130. package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
  131. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
  132. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
  133. package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
  134. package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
  135. package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
  136. package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
  137. package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
  138. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
  139. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
  140. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
  141. package/packages/dd-trace/src/config/config-types.d.ts +3 -0
  142. package/packages/dd-trace/src/config/defaults.js +9 -3
  143. package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
  144. package/packages/dd-trace/src/config/index.js +111 -43
  145. package/packages/dd-trace/src/config/parsers.js +18 -1
  146. package/packages/dd-trace/src/config/supported-configurations.json +174 -4
  147. package/packages/dd-trace/src/constants.js +1 -0
  148. package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
  149. package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
  150. package/packages/dd-trace/src/encode/0.4.js +2 -2
  151. package/packages/dd-trace/src/esm-module-load.js +58 -0
  152. package/packages/dd-trace/src/exporter.js +23 -15
  153. package/packages/dd-trace/src/exporters/agent/index.js +3 -1
  154. package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
  155. package/packages/dd-trace/src/exporters/common/request.js +83 -50
  156. package/packages/dd-trace/src/exporters/common/retry.js +12 -7
  157. package/packages/dd-trace/src/exporters/common/url.js +1 -1
  158. package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
  159. package/packages/dd-trace/src/exporters/log/index.js +4 -3
  160. package/packages/dd-trace/src/id.js +1 -1
  161. package/packages/dd-trace/src/lambda/facade.js +74 -0
  162. package/packages/dd-trace/src/lambda/handler.js +3 -41
  163. package/packages/dd-trace/src/lambda/index.js +38 -15
  164. package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
  165. package/packages/dd-trace/src/lambda/wrap.js +44 -0
  166. package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
  167. package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
  168. package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
  169. package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
  170. package/packages/dd-trace/src/llmobs/index.js +13 -2
  171. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
  172. package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
  173. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
  174. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
  175. package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
  176. package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
  177. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
  178. package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
  179. package/packages/dd-trace/src/llmobs/sdk.js +21 -1
  180. package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
  181. package/packages/dd-trace/src/llmobs/tagger.js +25 -0
  182. package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
  183. package/packages/dd-trace/src/log/channels.js +4 -0
  184. package/packages/dd-trace/src/log/writer.js +13 -2
  185. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
  186. package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
  187. package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
  188. package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
  189. package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
  190. package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
  191. package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
  192. package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
  193. package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
  194. package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
  195. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
  196. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
  197. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
  198. package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
  199. package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
  200. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
  201. package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
  202. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
  203. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
  204. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
  205. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
  206. package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
  207. package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
  208. package/packages/dd-trace/src/opentelemetry/span.js +2 -2
  209. package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
  210. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
  211. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
  212. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
  213. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
  214. package/packages/dd-trace/src/opentracing/tracer.js +33 -13
  215. package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
  216. package/packages/dd-trace/src/plugin_manager.js +34 -7
  217. package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
  218. package/packages/dd-trace/src/plugins/index.js +9 -0
  219. package/packages/dd-trace/src/plugins/plugin.js +4 -2
  220. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  221. package/packages/dd-trace/src/plugins/util/ci.js +18 -1
  222. package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
  223. package/packages/dd-trace/src/plugins/util/git.js +273 -86
  224. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
  225. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
  226. package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
  227. package/packages/dd-trace/src/plugins/util/tags.js +6 -0
  228. package/packages/dd-trace/src/plugins/util/test.js +90 -45
  229. package/packages/dd-trace/src/plugins/util/url.js +10 -2
  230. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
  231. package/packages/dd-trace/src/plugins/util/web.js +81 -10
  232. package/packages/dd-trace/src/process-tags/index.js +1 -1
  233. package/packages/dd-trace/src/profiling/config.js +6 -3
  234. package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
  235. package/packages/dd-trace/src/proxy.js +48 -57
  236. package/packages/dd-trace/src/serverless.js +3 -2
  237. package/packages/dd-trace/src/span_processor.js +41 -9
  238. package/packages/dd-trace/src/span_stats.js +28 -2
  239. package/packages/dd-trace/src/startup-log.js +8 -5
  240. package/packages/dd-trace/src/tagger.js +7 -5
  241. package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
  242. package/packages/dd-trace/src/telemetry/index.js +3 -0
  243. package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
  244. package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
  245. package/packages/dd-trace/src/telemetry/metrics.js +2 -1
  246. package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
  247. package/packages/dd-trace/src/tracer.js +0 -2
  248. package/packages/dd-trace/src/util.js +1 -1
  249. package/packages/dd-trace/src/web-tags-cache.js +8 -9
  250. package/register.js +4 -2
  251. package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
  252. package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
  253. package/vendor/dist/@datadog/flagging-core/index.js +1 -0
  254. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
  255. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  256. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
  257. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
  258. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
  259. package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
  260. package/vendor/dist/@datadog/source-map/LICENSE +1 -0
  261. package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
  262. package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
  263. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  264. package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
  265. package/vendor/dist/escape-string-regexp/LICENSE +13 -0
  266. package/vendor/dist/esquery/LICENSE +2 -0
  267. package/vendor/dist/https-proxy-agent/LICENSE +80 -1
  268. package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
  269. package/vendor/dist/jest-docblock/LICENSE +16 -0
  270. package/vendor/dist/jsonpath-plus/LICENSE +13 -0
  271. package/vendor/dist/limiter/LICENSE +2 -0
  272. package/vendor/dist/lodash.sortby/LICENSE +2 -0
  273. package/vendor/dist/lru-cache/LICENSE +13 -0
  274. package/vendor/dist/meriyah/LICENSE +13 -0
  275. package/vendor/dist/module-details-from-path/LICENSE +2 -0
  276. package/vendor/dist/mutexify/promise/LICENSE +28 -0
  277. package/vendor/dist/pprof-format/LICENSE +13 -0
  278. package/vendor/dist/pprof-format/index.js +1 -1
  279. package/vendor/dist/protobufjs/LICENSE +219 -0
  280. package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
  281. package/vendor/dist/proxy-from-env/LICENSE +13 -0
  282. package/vendor/dist/retry/LICENSE +2 -0
  283. package/vendor/dist/rfdc/LICENSE +2 -0
  284. package/vendor/dist/semifies/LICENSE +3 -1
  285. package/vendor/dist/shell-quote/LICENSE +3 -1
  286. package/vendor/dist/source-map/LICENSE +1 -0
  287. package/vendor/dist/source-map/lib/util/LICENSE +1 -0
  288. package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
  289. package/vendor/dist/ttl-set/LICENSE +28 -0
  290. package/ci/diagnose.js +0 -2215
  291. package/ci/runbook.md +0 -299
  292. package/ci/test-optimization-validation/approval-artifacts.js +0 -175
  293. package/ci/test-optimization-validation/approval.js +0 -386
  294. package/ci/test-optimization-validation/artifact-id.js +0 -19
  295. package/ci/test-optimization-validation/blocker-category.js +0 -24
  296. package/ci/test-optimization-validation/bounded-json.js +0 -120
  297. package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
  298. package/ci/test-optimization-validation/ci-discovery.js +0 -192
  299. package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
  300. package/ci/test-optimization-validation/ci-remediation.js +0 -283
  301. package/ci/test-optimization-validation/cli.js +0 -954
  302. package/ci/test-optimization-validation/command-blocker.js +0 -377
  303. package/ci/test-optimization-validation/command-output-policy.js +0 -188
  304. package/ci/test-optimization-validation/command-runner.js +0 -650
  305. package/ci/test-optimization-validation/environment.js +0 -88
  306. package/ci/test-optimization-validation/executable-approval.js +0 -47
  307. package/ci/test-optimization-validation/executable.js +0 -244
  308. package/ci/test-optimization-validation/execution-lock.js +0 -70
  309. package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
  310. package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
  311. package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
  312. package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
  313. package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
  314. package/ci/test-optimization-validation/generated-file-policy.js +0 -63
  315. package/ci/test-optimization-validation/generated-files.js +0 -425
  316. package/ci/test-optimization-validation/generated-test-contract.js +0 -284
  317. package/ci/test-optimization-validation/generated-verifier.js +0 -235
  318. package/ci/test-optimization-validation/literal-environment.js +0 -56
  319. package/ci/test-optimization-validation/literal-glob.js +0 -52
  320. package/ci/test-optimization-validation/manifest-loader.js +0 -116
  321. package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
  322. package/ci/test-optimization-validation/manifest-schema.js +0 -695
  323. package/ci/test-optimization-validation/offline-fixtures.js +0 -335
  324. package/ci/test-optimization-validation/offline-output.js +0 -406
  325. package/ci/test-optimization-validation/package-check.js +0 -97
  326. package/ci/test-optimization-validation/payload-normalizer.js +0 -72
  327. package/ci/test-optimization-validation/plan-writer.js +0 -541
  328. package/ci/test-optimization-validation/preflight-runner.js +0 -186
  329. package/ci/test-optimization-validation/project-build-artifact.js +0 -31
  330. package/ci/test-optimization-validation/redaction.js +0 -319
  331. package/ci/test-optimization-validation/report-writer.js +0 -666
  332. package/ci/test-optimization-validation/result-semantics.js +0 -103
  333. package/ci/test-optimization-validation/runner-command.js +0 -264
  334. package/ci/test-optimization-validation/runner-contract.js +0 -695
  335. package/ci/test-optimization-validation/safe-files.js +0 -202
  336. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
  337. package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
  338. package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
  339. package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
  340. package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
  341. package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
  342. package/ci/test-optimization-validation/source-text.js +0 -84
  343. package/ci/test-optimization-validation/static-diagnosis.js +0 -166
  344. package/ci/test-optimization-validation/test-output.js +0 -120
  345. package/ci/test-optimization-validation/validation-blocker.js +0 -21
  346. package/ci/validate-test-optimization.js +0 -3
  347. package/packages/datadog-esbuild/src/resolver.js +0 -284
  348. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
  349. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
  350. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
  351. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
  352. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
  353. 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,
@@ -187,12 +188,12 @@ const efdSlowAbortedTests = new Set()
187
188
  const efdCandidates = new Set()
188
189
  // Per-declaration dynamic ATR retry count, retained across attempts of the same Jest test object.
189
190
  const dynamicAtrRetryCountByTest = new Map()
190
- // 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
191
192
  // temporarily cleared to keep that ceiling from scheduling another retry, then
192
193
  // restored before Jest reports the suite result.
193
- const dynamicAtrFinalErrorsByTest = new Map()
194
+ const terminalRetryErrorsByTest = new Map()
194
195
  // Custom environments may prevent extensions after their base constructor runs.
195
- const dynamicAtrResultHandlerRegistrations = new WeakMap()
196
+ const retryResultHandlerRegistrations = new WeakMap()
196
197
  // Tests that are genuinely new (not in known tests list).
197
198
  const newTests = new Set()
198
199
  const testSuiteJestObjects = new Map()
@@ -266,6 +267,22 @@ let jestEachBind
266
267
  // Track quarantined tests whose errors were suppressed, keyed by "suite › testName"
267
268
  const quarantinedFailingTests = new Set()
268
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
+
269
286
  function getJestRepositoryRoot (readConfigsResult) {
270
287
  const configuredRepositoryRoot = readConfigsResult.configs
271
288
  ?.find(config => config.testEnvironmentOptions?._ddRepositoryRoot)
@@ -440,9 +457,9 @@ function getAttemptToFixExecutionsFromJestResults (result) {
440
457
  ?.tests
441
458
  if (!testManagementTestsForSuite) continue
442
459
 
443
- for (const { fullName, status } of testResults) {
460
+ for (const { fullName, status, _ddTestAnnotations } of testResults) {
444
461
  const testName = removeSeedSuffixFromTestName(fullName)
445
- const testManagementTest = testManagementTestsForSuite[testName]?.properties
462
+ const testManagementTest = getEffectiveManagementProperties(testSuite, testName, _ddTestAnnotations)
446
463
  if (!testManagementTest?.attempt_to_fix) continue
447
464
  const testStatus = getTestStatusFromJestResult(status) ||
448
465
  (status === 'pending' || status === 'todo' ? 'skip' : undefined)
@@ -488,9 +505,9 @@ function recordTestManagementExecutionsFromJestResults (result, quarantineFailur
488
505
  ?.tests
489
506
  if (!testManagementTestsForSuite) continue
490
507
 
491
- for (const { fullName, status } of testResults) {
508
+ for (const { fullName, status, _ddTestAnnotations } of testResults) {
492
509
  const testName = removeSeedSuffixFromTestName(fullName)
493
- const testManagementTest = testManagementTestsForSuite[testName]?.properties
510
+ const testManagementTest = getEffectiveManagementProperties(testSuite, testName, _ddTestAnnotations)
494
511
  if (!testManagementTest) continue
495
512
 
496
513
  const name = `${testSuite} › ${testName}`
@@ -564,8 +581,8 @@ function setOriginalConcurrentTest (wrappedConcurrentTest, originalConcurrentTes
564
581
  *
565
582
  * @param {{ name: string, test?: { errors: unknown[] } }} event
566
583
  */
567
- function suppressDynamicAtrErrors (event) {
568
- if (event.name === 'test_done' && dynamicAtrFinalErrorsByTest.has(event.test)) {
584
+ function suppressTerminalRetryErrors (event) {
585
+ if (event.name === 'test_done' && terminalRetryErrorsByTest.has(event.test)) {
569
586
  event.test.errors = []
570
587
  }
571
588
  }
@@ -575,13 +592,13 @@ function suppressDynamicAtrErrors (event) {
575
592
  *
576
593
  * @param {{ name: string }} event
577
594
  */
578
- function restoreDynamicAtrErrors (event) {
579
- 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
580
597
 
581
- for (const [test, errors] of dynamicAtrFinalErrorsByTest) {
598
+ for (const [test, errors] of terminalRetryErrorsByTest) {
582
599
  test.errors = errors
583
600
  }
584
- dynamicAtrFinalErrorsByTest.clear()
601
+ terminalRetryErrorsByTest.clear()
585
602
  }
586
603
 
587
604
  /**
@@ -602,7 +619,7 @@ function getWrappedCustomHandleTestEvent (handleTestEvent, datadogHandleTestEven
602
619
  }
603
620
 
604
621
  const wrappedHandleTestEvent = function (event, state) {
605
- restoreDynamicAtrErrors(event)
622
+ restoreTerminalRetryErrors(event)
606
623
  const result = handleTestEvent.call(this, event, state)
607
624
  const runDatadogHandler = value => {
608
625
  if (isDatadogJestEventHandled(event)) return value
@@ -666,6 +683,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
666
683
 
667
684
  return class DatadogEnvironment extends BaseEnvironment {
668
685
  #activeDetachedEfdRetries
686
+ #boundTestEach = new WeakSet()
687
+ #describeRetryAttempts
669
688
  #detachedEfdRetryConcurrency
670
689
  #detachedEfdRetryQueue
671
690
  #discardedEfdRetryTests
@@ -673,6 +692,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
673
692
  #efdRetryGatesByName
674
693
  #expect
675
694
  #pendingPre30ConcurrentTests
695
+ #registeringConcurrentTestState
696
+ /** @type {Map<object, { finish: (finalStatus?: string) => void, finalStatus: string }>|undefined} */
697
+ #pendingDescribeRetryFinishes
676
698
  /** @type {(() => void)|undefined} */
677
699
  #restoreSnapshotState
678
700
  /** @type {Set<string>|undefined} */
@@ -744,6 +766,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
744
766
  }
745
767
 
746
768
  this.hasAutomaticRetries = false
769
+ this.testResultAnnotations = []
770
+ this.hasExplicitRetries = !!this.global[RETRY_TIMES]
747
771
  if (this.isFlakyTestRetriesEnabled) {
748
772
  const currentNumRetries = this.global[RETRY_TIMES]
749
773
  if (!currentNumRetries) {
@@ -814,9 +838,11 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
814
838
  * Rebuilds serial `test.each` so every generated row function keeps its parameters.
815
839
  *
816
840
  * @param {Function|undefined} test
841
+ * @param {boolean} needsEachError
817
842
  */
818
- bindTestEach (test) {
819
- 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)
820
846
 
821
847
  const bind = this.getJestEachBind()
822
848
  if (typeof bind !== 'function') {
@@ -839,6 +865,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
839
865
  const testParameters = getFormattedJestTestParameters(eachArgs)
840
866
  return function (...testArgs) {
841
867
  let parameterIndex = 0
868
+ const sourceTestFn = testArgs[1]
842
869
  const eachTest = function (testName, testFn, ...callArgs) {
843
870
  const parameters = testParameters?.[parameterIndex++]
844
871
  if (parameters !== undefined && typeof testFn === 'function') {
@@ -848,15 +875,26 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
848
875
  getTestParametersString(environment.nameToParams, testName)
849
876
  )
850
877
  }
878
+ copyTestAnnotations(sourceTestFn, testFn)
851
879
  return test.call(this, testName, testFn, ...callArgs)
852
880
  }
853
- const boundTest = bind(eachTest)
881
+ const boundTest = bind(eachTest, !needsEachError, needsEachError)
854
882
  const eachBind = boundTest.apply(this, eachArgs)
855
883
  return eachBind.apply(this, testArgs)
856
884
  }
857
885
  }
858
886
  }
859
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
+
860
898
  /**
861
899
  * Wraps Jest's concurrent test registration methods so eager concurrent bodies
862
900
  * in older Jest versions execute inside their test span context.
@@ -921,7 +959,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
921
959
  sourceTestFn: environment.concurrentTestSourceFns.get(testFn),
922
960
  timeout: args[0],
923
961
  })
924
- return concurrentTest.call(this, testName, wrappedTestFn, ...args)
962
+ return environment.registerConcurrentTest(concurrentTest, this, testName, wrappedTestFn, ...args)
925
963
  }
926
964
  })
927
965
 
@@ -931,6 +969,25 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
931
969
  this.bindConcurrentEach(wrappedConcurrentTest, methodName === 'failing')
932
970
  }
933
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
+
934
991
  /**
935
992
  * Rebuilds a concurrent `.each` helper so each generated row calls the wrapped test function.
936
993
  *
@@ -955,6 +1012,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
955
1012
  environment.appendNameToParams(testName, parameters)
956
1013
  }
957
1014
  if (typeof testFn === 'function' && typeof sourceTestFn === 'function') {
1015
+ copyTestAnnotations(sourceTestFn, testFn)
958
1016
  environment.concurrentTestSourceFns.set(testFn, sourceTestFn)
959
1017
  }
960
1018
  return concurrentTest.call(this, testName, testFn, ...callArgs)
@@ -990,6 +1048,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
990
1048
  const wrappedTestFn = shimmer.wrapFunction(testFn, testFn => function (...args) {
991
1049
  return environment.runConcurrentTestFn(concurrentTestState, testFn, this, args)
992
1050
  })
1051
+ copyTestAnnotations(options?.sourceTestFn || testFn, wrappedTestFn)
993
1052
  this.concurrentTestStates.set(wrappedTestFn, concurrentTestState)
994
1053
  return wrappedTestFn
995
1054
  }
@@ -1036,9 +1095,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1036
1095
  createConcurrentTestContext (testName, testFn, asyncError, state, options) {
1037
1096
  const testFullName = this.getTestNameFromAddTestEvent({ testName }, state)
1038
1097
  const isNewTest = this.isKnownTestsEnabled && !this.knownTestsForThisSuite?.includes(testFullName)
1039
- const isAttemptToFix = this.isTestManagementTestsEnabled &&
1040
- this.testManagementTestsForThisSuite?.attemptToFix?.includes(testFullName)
1041
1098
  const sourceTestFn = options?.sourceTestFn || testFn
1099
+ const policy = this.getTestPolicy(testFullName, sourceTestFn)
1042
1100
  const ctx = {
1043
1101
  name: testFullName,
1044
1102
  suite: this.testSuite,
@@ -1050,11 +1108,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1050
1108
  isEfdRetry: options?.isEfdRetry === true,
1051
1109
  efdRetryGates: options?.efdRetryGates,
1052
1110
  efdRetryIndex: options?.efdRetryIndex,
1053
- isAttemptToFix,
1111
+ ...policy,
1054
1112
  isAttemptToFixRetry: options?.isAttemptToFixRetry === true,
1055
1113
  isJestRetry: false,
1056
- isDisabled: this.testManagementTestsForThisSuite?.disabled?.includes(testFullName),
1057
- isQuarantined: this.testManagementTestsForThisSuite?.quarantined?.includes(testFullName),
1058
1114
  isModified: options?.isModified ?? this.isTestModified(asyncError, sourceTestFn),
1059
1115
  hasDynamicName: isNewTest && DYNAMIC_NAME_RE.test(testFullName),
1060
1116
  testSuiteAbsolutePath: this.testSuiteAbsolutePath,
@@ -1080,7 +1136,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1080
1136
  if (!this.isImpactedTestsEnabled || !asyncError || typeof testFn !== 'function') return false
1081
1137
 
1082
1138
  const testStartLine = getTestLineStart(asyncError, this.testSuite)
1083
- const testEndLine = getTestEndLine(testFn, testStartLine)
1139
+ const testEndLine = getTestEndLine(getTestAnnotations(testFn).source || testFn, testStartLine)
1084
1140
  return isModifiedTest(
1085
1141
  this.testSourceFile,
1086
1142
  testStartLine,
@@ -1548,6 +1604,27 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1548
1604
  }
1549
1605
  }
1550
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
+
1551
1628
  // This function returns an array if the known tests are valid and null otherwise.
1552
1629
  getKnownTestsForSuite (suiteKnownTests) {
1553
1630
  // `suiteKnownTests` is `this.testEnvironmentOptions._ddKnownTests`,
@@ -1675,7 +1752,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1675
1752
  timeout,
1676
1753
  }
1677
1754
  )
1678
- test.call(concurrentTestState.concurrentTestThisArg, testName, retryFn, timeout)
1755
+ this.registerConcurrentTest(test, concurrentTestState.concurrentTestThisArg, testName, retryFn, timeout)
1679
1756
  } else if (this.global.test) {
1680
1757
  const test = mode === 'only' ? this.global.test.only : this.global.test
1681
1758
  // The child-count check below proves Jest added a node, so retries can share the test
@@ -1932,9 +2009,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1932
2009
  }
1933
2010
 
1934
2011
  const testFullName = this.getTestNameFromAddTestEvent(event, state)
1935
- const concurrentTestContexts = this.concurrentTestContexts.get(testFullName)
1936
2012
  const concurrentTestState = this.concurrentTestStates.get(event.fn) ||
1937
- concurrentTestContexts?.at(-1)?.concurrentTestState
2013
+ this.#registeringConcurrentTestState
1938
2014
  if (concurrentTestState && registeredTest?.fn === event.fn) {
1939
2015
  testContexts.set(registeredTest, concurrentTestState.ctx)
1940
2016
  }
@@ -1942,10 +2018,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1942
2018
  return
1943
2019
  }
1944
2020
  const isSkipped = event.mode === 'todo' || event.mode === 'skip'
1945
- const isAttemptToFix = this.isTestManagementTestsEnabled &&
1946
- this.testManagementTestsForThisSuite?.attemptToFix?.includes(testFullName)
1947
- const isDisabled = this.isTestManagementTestsEnabled &&
1948
- this.testManagementTestsForThisSuite?.disabled?.includes(testFullName)
2021
+ const { isAttemptToFix, isDisabled, noAutoRetry } = this.getTestPolicy(testFullName, event.fn)
1949
2022
  if (isAttemptToFix && !isSkipped) {
1950
2023
  retriedTestsToNumAttempts.set(testFullName, 0)
1951
2024
  testsToBeRetried.add(testFullName)
@@ -1979,6 +2052,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
1979
2052
  }
1980
2053
 
1981
2054
  if (
2055
+ noAutoRetry ||
1982
2056
  isAttemptToFix ||
1983
2057
  isDisabled ||
1984
2058
  isSkipped ||
@@ -2025,21 +2099,24 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2025
2099
  this.handleAddTestEvent(event, state)
2026
2100
  }
2027
2101
 
2028
- restoreDynamicAtrErrors(event)
2102
+ restoreTerminalRetryErrors(event)
2029
2103
 
2030
2104
  if (super.handleTestEvent) {
2031
2105
  await super.handleTestEvent(event, state)
2032
2106
  }
2033
2107
 
2034
2108
  if (event.name === 'run_start') {
2109
+ this.#finishPendingDescribeRetries()
2110
+ this.#describeRetryAttempts = undefined
2035
2111
  this.#trackQuarantinedSnapshots()
2036
- const registerResultHandler = dynamicAtrResultHandlerRegistrations.get(this)
2037
- dynamicAtrResultHandlerRegistrations.delete(this)
2112
+ const registerResultHandler = retryResultHandlerRegistrations.get(this)
2113
+ retryResultHandlerRegistrations.delete(this)
2038
2114
  registerResultHandler?.()
2039
2115
  } else if (event.name === 'setup') {
2040
2116
  this.#expect = event.runtimeGlobals?.expect ?? this.global.expect
2041
2117
  this.wrapConcurrentTest(state)
2042
- this.bindTestEach(this.global.test)
2118
+ this.wrapConcurrentTestGlobals(event.runtimeGlobals?.test, state)
2119
+ this.bindTestEachGlobals(event.runtimeGlobals?.test ?? this.global.test)
2043
2120
  }
2044
2121
  if (
2045
2122
  event.name === 'run_describe_start' &&
@@ -2049,20 +2126,38 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2049
2126
  ) {
2050
2127
  this.preparePre30ConcurrentTests(event.describeBlock, state)
2051
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
+ }
2052
2142
  if (event.name === 'concurrent_tests_start') {
2053
2143
  this.orderConcurrentEfdRetries(event.tests)
2054
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
+ }
2055
2151
  const testName = getJestTestName(event.test)
2056
- let isAttemptToFix = false
2057
- let isDisabled = false
2058
- let isQuarantined = false
2059
- if (this.isTestManagementTestsEnabled) {
2060
- isAttemptToFix = this.testManagementTestsForThisSuite?.attemptToFix?.includes(testName)
2061
- isDisabled = this.testManagementTestsForThisSuite?.disabled?.includes(testName)
2062
- isQuarantined = this.testManagementTestsForThisSuite?.quarantined?.includes(testName)
2063
- if (!isAttemptToFix && isDisabled) {
2064
- event.test.mode = 'skip'
2065
- }
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'
2066
2161
  }
2067
2162
  if (
2068
2163
  event.test.mode === 'todo' ||
@@ -2071,13 +2166,10 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2071
2166
  return
2072
2167
  }
2073
2168
 
2074
- const registeredConcurrentTestState = testContexts.get(event.test)?.concurrentTestState
2075
- const concurrentTestState = this.concurrentTestStates.get(event.test.fn) ||
2076
- registeredConcurrentTestState
2077
2169
  let concurrentCtx = concurrentTestState?.ctx
2078
2170
  if (concurrentCtx) {
2079
2171
  this.removeConcurrentTestContext(testName, concurrentCtx)
2080
- } else {
2172
+ } else if (event.test.concurrent) {
2081
2173
  concurrentCtx = this.getNextConcurrentTestContext(testName)
2082
2174
  }
2083
2175
  if (hasConcurrentTestsStartEvent && concurrentCtx?.efdRetryGates) {
@@ -2119,7 +2211,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2119
2211
  isNewTest = newTests.has(testName)
2120
2212
  }
2121
2213
 
2122
- const willRunEfd = this.isEarlyFlakeDetectionEnabled &&
2214
+ const willRunEfd = !noAutoRetry && this.isEarlyFlakeDetectionEnabled &&
2123
2215
  hasEfdRetries(this.#earlyFlakeDetectionRetryPolicy) &&
2124
2216
  (isNewTest || isModified)
2125
2217
  event.test[ATR_RETRY_SUPPRESSION_FLAG] = Boolean(isAttemptToFix || willRunEfd)
@@ -2144,6 +2236,25 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2144
2236
  ctx.isAttemptToFix = isAttemptToFix
2145
2237
  ctx.isAttemptToFixRetry ||= numOfAttemptsToFixRetries > 0
2146
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
2147
2258
  ctx.isDisabled = isDisabled
2148
2259
  ctx.isQuarantined = isQuarantined
2149
2260
  ctx.isModified = isModified
@@ -2296,7 +2407,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2296
2407
  let isAttemptToFix = false
2297
2408
  const testName = getJestTestName(event.test)
2298
2409
  if (this.isTestManagementTestsEnabled) {
2299
- isAttemptToFix = this.testManagementTestsForThisSuite?.attemptToFix?.includes(testName)
2410
+ isAttemptToFix = retryCtx?.isAttemptToFix === true
2300
2411
  if (isAttemptToFix) {
2301
2412
  if (attemptToFixRetriedTestsStatuses.has(testName)) {
2302
2413
  attemptToFixRetriedTestsStatuses.get(testName).push(status)
@@ -2322,6 +2433,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2322
2433
 
2323
2434
  // The first execution selects how many pre-registered EFD retries remain runnable.
2324
2435
  if (
2436
+ !retryCtx?.noAutoRetry &&
2325
2437
  this.isEarlyFlakeDetectionEnabled &&
2326
2438
  efdCandidates.has(testName) &&
2327
2439
  event.test.invocations === 1 &&
@@ -2334,7 +2446,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2334
2446
  }
2335
2447
 
2336
2448
  const isEfdRetry = retryCtx?.isEfdRetry === true
2337
- if (efdCandidates.has(testName)) {
2449
+ if (!retryCtx?.noAutoRetry && efdCandidates.has(testName)) {
2338
2450
  let testStatuses = efdTestStatuses.get(testName)
2339
2451
  if (testStatuses) {
2340
2452
  testStatuses.push(status)
@@ -2350,7 +2462,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2350
2462
  }
2351
2463
 
2352
2464
  // ATR: set failedAllTests when all auto test retries were exhausted and every attempt failed
2353
- if (this.isFlakyTestRetriesEnabled && !isAttemptToFix && !isEfdRetry) {
2465
+ if (this.isFlakyTestRetriesEnabled && !retryCtx?.noAutoRetry && !isAttemptToFix && !isEfdRetry) {
2354
2466
  // Dynamic ATR: after the first attempt, compute the duration-based retry budget.
2355
2467
  if (
2356
2468
  this.isDynamicAtrEnabled &&
@@ -2378,14 +2490,18 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2378
2490
  const numRetries = this.global[RETRY_TIMES]
2379
2491
  const numTestExecutions = event.test?.invocations
2380
2492
  // Dynamic ATR: use the per-test duration-based count instead of the global flat limit.
2381
- const dynamicAtrCount = this.isDynamicAtrEnabled && dynamicAtrRetryCountByTest.has(event.test)
2382
- ? dynamicAtrRetryCountByTest.get(event.test)
2383
- : 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
2384
2499
  const effectiveMaxRetries = dynamicAtrCount === undefined ? numRetries : dynamicAtrCount
2385
2500
  const willBeRetriedByAutoTestRetry = effectiveMaxRetries > 0 && numTestExecutions - 1 < effectiveMaxRetries
2386
2501
  const isFailedTestReplayAllowed = !this.hasConcurrentTests
2387
2502
  const willBeRetriedByFailedTestReplay = isFailedTestReplayAllowed && willBeRetriedByAutoTestRetry
2388
- const mightHitBreakpoint = this.isDiEnabled && isFailedTestReplayAllowed && numTestExecutions >= 2
2503
+ const mightHitBreakpoint = !retryCtx?.noAutoRetry && this.isDiEnabled &&
2504
+ isFailedTestReplayAllowed && numTestExecutions >= 2
2389
2505
 
2390
2506
  // For quarantined tests, track failures so the session can be marked as passing later,
2391
2507
  // and suppress errors so Jest does not mark the test suite as failing.
@@ -2401,8 +2517,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2401
2517
  this.ignoreQuarantinedSnapshotResults(event.test)
2402
2518
 
2403
2519
  // Quarantine must consume terminal failures before we save errors for Jest's final result.
2404
- if (dynamicAtrCount !== undefined && failedAllTests && event.test.errors?.length) {
2405
- 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)
2406
2523
  }
2407
2524
 
2408
2525
  const ctx = testContexts.get(event.test)
@@ -2431,7 +2548,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2431
2548
  isEfdRetry,
2432
2549
  isAttemptToFix,
2433
2550
  numTestExecutions,
2434
- dynamicAtrCount)
2551
+ dynamicAtrCount,
2552
+ ctx)
2435
2553
 
2436
2554
  if (status === 'fail') {
2437
2555
  const shouldSetProbe = this.isDiEnabled && willBeRetriedByFailedTestReplay && numTestExecutions === 1
@@ -2457,14 +2575,20 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2457
2575
  break
2458
2576
  }
2459
2577
  }
2460
- if (this.isFlakyTestRetriesEnabled && hasAutomaticRetries &&
2578
+ if (this.isFlakyTestRetriesEnabled && !ctx.noAutoRetry && hasAutomaticRetries &&
2461
2579
  event.test?.invocations > 1 && !isAttemptToFix && !isEfdRetry) {
2462
2580
  isAtrRetry = true
2463
2581
  }
2464
2582
 
2583
+ /** @type {{ finish?: (finalStatus?: string) => void }|undefined} */
2584
+ const deferredFinish = ctx.noAutoRetry &&
2585
+ ctx.hasDescribeRetriesRemaining && !finalStatus
2586
+ ? {}
2587
+ : undefined
2465
2588
  testFinishCh.publish({
2466
2589
  ...ctx.currentStore,
2467
2590
  status,
2591
+ deferredFinish,
2468
2592
  testStartLine: getTestLineStart(event.test.asyncError, this.testSuite),
2469
2593
  attemptToFixPassed,
2470
2594
  failedAllTests,
@@ -2474,6 +2598,13 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2474
2598
  earlyFlakeAbortReason: efdSlowAbortedTests.has(testName) ? 'slow' : undefined,
2475
2599
  promises,
2476
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
+ }
2477
2608
 
2478
2609
  if (promises.hitBreakpointPromise) {
2479
2610
  await promises.hitBreakpointPromise
@@ -2485,9 +2616,29 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2485
2616
  ctx.currentStore = undefined
2486
2617
  }
2487
2618
  } else if (event.name === 'run_finish') {
2619
+ this.#finishPendingDescribeRetries()
2488
2620
  this.#restoreSnapshotState?.()
2489
2621
  this.#restoreSnapshotState = undefined
2490
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
+ }
2491
2642
  for (const [test, errors] of atrSuppressedErrors) {
2492
2643
  // Do not restore errors for non-ATF quarantined tests — they should stay suppressed
2493
2644
  // so Jest doesn't see the failure (prevents --bail from stopping the run).
@@ -2535,8 +2686,10 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2535
2686
  } else {
2536
2687
  this.discardEfdRetries(testName, event.test)
2537
2688
  }
2689
+ const policy = this.getTestPolicy(testName, event.test.fn)
2538
2690
  testSkippedCh.publish({
2539
2691
  test: {
2692
+ ...policy,
2540
2693
  name: testName,
2541
2694
  suite: this.testSuite,
2542
2695
  testSourceFile: this.testSourceFile,
@@ -2544,7 +2697,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2544
2697
  frameworkVersion: jestVersion,
2545
2698
  testStartLine: getTestLineStart(event.test.asyncError, this.testSuite),
2546
2699
  },
2547
- isDisabled: this.testManagementTestsForThisSuite?.disabled?.includes(testName),
2700
+ isDisabled: policy.isDisabled,
2548
2701
  })
2549
2702
  }
2550
2703
  }
@@ -2608,8 +2761,18 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2608
2761
  isEfdRetry,
2609
2762
  isAttemptToFix,
2610
2763
  numberOfTestInvocations,
2611
- dynamicAtrRetryCount
2764
+ dynamicAtrRetryCount,
2765
+ ctx
2612
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
+ }
2613
2776
  const numberOfExecutedRetries = retriedTestsToNumAttempts.get(testName) ?? 0
2614
2777
 
2615
2778
  const efdResult = this.getEfdResult({
@@ -2647,15 +2810,22 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
2647
2810
  // If the test is quarantined, regardless of its actual execution result,
2648
2811
  // the final status of its last execution should be reported as 'skip'.
2649
2812
  if (!attemptToFixResult.isAttemptToFixEnabled &&
2650
- this.isTestManagementTestsEnabled &&
2651
- this.testManagementTestsForThisSuite?.quarantined?.includes(testName)) {
2813
+ ctx.isQuarantined) {
2652
2814
  return 'skip'
2653
2815
  }
2654
2816
 
2655
2817
  return efdResult.finalStatus || attemptToFixResult.finalStatus || atrResult.finalStatus
2656
2818
  }
2657
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
+
2658
2827
  teardown () {
2828
+ this.#finishPendingDescribeRetries()
2659
2829
  this.#restoreSnapshotState?.()
2660
2830
  this.#restoreSnapshotState = undefined
2661
2831
  if (this._globalProxy?.propertyToValue) {
@@ -3108,7 +3278,9 @@ function searchSourceWrapper (searchSourcePackage, frameworkVersion) {
3108
3278
  getIsFaultyEarlyFlakeDetection(projectSuites, knownTests.jest, earlyFlakeDetectionFaultyThreshold)
3109
3279
 
3110
3280
  if (isFaulty) {
3111
- 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.')
3112
3284
  isEarlyFlakeDetectionEnabled = false
3113
3285
  isKnownTestsEnabled = false
3114
3286
  const testEnvironmentOptions = testPaths.tests[0]?.context?.config?.testEnvironmentOptions
@@ -3356,26 +3528,21 @@ function getCliWrapper (isNewJestVersion) {
3356
3528
  const failedTests = result
3357
3529
  .results
3358
3530
  .testResults.flatMap(({ testResults, testFilePath: testSuiteAbsolutePath }) => (
3359
- testResults.map(({ fullName: testName, status }) => (
3531
+ testResults.map(({ fullName: testName, status, _ddTestAnnotations }) => (
3360
3532
  {
3361
3533
  // Strip seed suffix so the name matches what was reported via TEST_NAME.
3362
3534
  testName: removeSeedSuffixFromTestName(testName),
3363
3535
  testSuiteAbsolutePath,
3364
3536
  status,
3537
+ _ddTestAnnotations,
3365
3538
  }
3366
3539
  ))
3367
3540
  ))
3368
3541
  .filter(({ status }) => status === 'failed')
3369
3542
 
3370
- for (const { testName, testSuiteAbsolutePath } of failedTests) {
3543
+ for (const { testName, testSuiteAbsolutePath, _ddTestAnnotations } of failedTests) {
3371
3544
  const testSuite = getTestSuitePath(testSuiteAbsolutePath, result.globalConfig.rootDir)
3372
- const testManagementTest = testManagementTests
3373
- ?.jest
3374
- ?.suites
3375
- ?.[testSuite]
3376
- ?.tests
3377
- ?.[testName]
3378
- ?.properties
3545
+ const testManagementTest = getEffectiveManagementProperties(testSuite, testName, _ddTestAnnotations)
3379
3546
  if (testManagementTest?.quarantined && !testManagementTest?.attempt_to_fix) {
3380
3547
  numFailedQuarantinedTests++
3381
3548
  quarantineIgnoredNames.push(`${testSuite} › ${testName}`)
@@ -3659,14 +3826,14 @@ function jestAdapterWrapper (jestAdapter, jestVersion, isIitm, hookMeta) {
3659
3826
 
3660
3827
  wrapEnvironmentCustomHandleTestEvent(environment)
3661
3828
 
3662
- if (environment.isDynamicAtrEnabled && environment.isFlakyTestRetriesEnabled) {
3829
+ if (environment.isFlakyTestRetriesEnabled) {
3663
3830
  // Register at run_start, after Circus installs its per-test reporter and snapshot handlers.
3664
- dynamicAtrResultHandlerRegistrations.set(environment, () => {
3831
+ retryResultHandlerRegistrations.set(environment, () => {
3665
3832
  if (satisfies(jestVersion, '>=30.0.0')) {
3666
- environment.global[Symbol.for('EVENT_HANDLERS')].push(suppressDynamicAtrErrors)
3833
+ environment.global[Symbol.for('EVENT_HANDLERS')].push(suppressTerminalRetryErrors)
3667
3834
  } else {
3668
3835
  const circusState = args[3].requireInternalModule(path.join(hookMeta.moduleBaseDir, 'build/state.js'))
3669
- circusState.addEventHandler(suppressDynamicAtrErrors)
3836
+ circusState.addEventHandler(suppressTerminalRetryErrors)
3670
3837
  }
3671
3838
  })
3672
3839
  }
@@ -3680,6 +3847,9 @@ function jestAdapterWrapper (jestAdapter, jestVersion, isIitm, hookMeta) {
3680
3847
  testSuiteAbsolutePath: environment.testSuiteAbsolutePath,
3681
3848
  })
3682
3849
  return adapter.apply(this, args).then(suiteResults => {
3850
+ for (const [index, result] of suiteResults.testResults.entries()) {
3851
+ result._ddTestAnnotations = environment.testResultAnnotations?.[index]
3852
+ }
3683
3853
  const { numFailingTests, skipped, failureMessage: errorMessage } = suiteResults
3684
3854
  let status = 'pass'
3685
3855
  if (skipped) {
@@ -4029,8 +4199,11 @@ function wrapJestObject (jestObject, suiteFilePath, from = suiteFilePath) {
4029
4199
  // retryTimes is created per runtime, so wrap the returned public API object.
4030
4200
  shimmer.wrap(jestObject, 'retryTimes', retryTimes => function () {
4031
4201
  const environment = testSuiteDatadogEnvironments.get(suiteFilePath)
4202
+ const setsDescribeRetries = arguments[1]?.entireDescribe &&
4203
+ typeof environment?.global[RETRY_TIMES_SETTER] === 'function'
4032
4204
  // Older Jest versions ignore entireDescribe and still replace the global budget.
4033
- if (environment && !(arguments[1]?.entireDescribe && environment.global[RETRY_TIMES_SETTER])) {
4205
+ if (environment && !setsDescribeRetries) {
4206
+ environment.hasExplicitRetries = true
4034
4207
  environment.hasAutomaticRetries = false
4035
4208
  }
4036
4209
  return retryTimes.apply(this, arguments)
@@ -4058,6 +4231,7 @@ function wrapJestGlobalsForRuntime (runtime) {
4058
4231
 
4059
4232
  function wrapConcurrentJestGlobalsForRuntime (runtime, jestGlobals) {
4060
4233
  const environment = testSuiteDatadogEnvironments.get(runtime?._testPath)
4234
+ environment?.bindTestEachGlobals(jestGlobals?.test)
4061
4235
  environment?.wrapConcurrentTestGlobals(jestGlobals?.test, environment.concurrentTestState)
4062
4236
  }
4063
4237
 
@@ -4343,6 +4517,15 @@ addHook({
4343
4517
  }, (runtimePackage) => {
4344
4518
  const Runtime = runtimePackage.default ?? runtimePackage
4345
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
+
4346
4529
  if (typeof Runtime.prototype._createJestObjectFor === 'function') {
4347
4530
  shimmer.wrap(Runtime.prototype, '_createJestObjectFor', _createJestObjectFor => function (from) {
4348
4531
  const result = _createJestObjectFor.apply(this, arguments)
@@ -4464,7 +4647,7 @@ function onMessageWrapper (onMessage) {
4464
4647
 
4465
4648
  const [code, data] = response
4466
4649
  if (code === JEST_WORKER_TRACE_PAYLOAD_CODE) { // datadog trace payload
4467
- collectDynamicNamesFromTraces(data, newTestsWithDynamicNames)
4650
+ collectTestOptimizationSummariesFromTraces(data, { newTestsWithDynamicNames })
4468
4651
  workerReportTraceCh.publish(data)
4469
4652
  return
4470
4653
  }