dd-trace 6.22.0 → 6.24.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.
- package/LICENSE-3rdparty.csv +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/diagnose.js +4 -4
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/test-optimization-validation/approval-artifacts.js +2 -2
- package/ci/test-optimization-validation/approval.js +2 -2
- package/ci/test-optimization-validation/artifact-id.js +2 -3
- package/ci/test-optimization-validation/ci-package-scripts.js +1 -1
- package/ci/test-optimization-validation/cli.js +1 -1
- package/ci/test-optimization-validation/command-runner.js +2 -3
- package/ci/test-optimization-validation/executable.js +1 -1
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +1 -1
- package/ci/test-optimization-validation/literal-environment.js +2 -2
- package/ci/test-optimization-validation/manifest-scaffold.js +1 -1
- package/ci/test-optimization-validation/offline-fixtures.js +1 -1
- package/ci/test-optimization-validation/redaction.js +3 -3
- package/ci/test-optimization-validation/runner-contract.js +10 -10
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +1 -1
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -5
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -0
- package/index.d.ts +35 -5
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +23 -20
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +70 -7
- package/packages/datadog-instrumentations/index.js +2 -1
- package/packages/datadog-instrumentations/src/cucumber.js +64 -21
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/graphql.js +9 -3
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +27 -8
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +16 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +10 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/jest.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/vitest.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +13 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +332 -137
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +92 -13
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/nova-sonic/session.js +25 -16
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -26
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/stripe.js +23 -12
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -47
- package/packages/datadog-instrumentations/src/vitest-main.js +33 -3
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +5 -2
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +16 -6
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +277 -44
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -437
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +143 -1
- package/packages/dd-trace/src/aiguard/sdk.js +0 -11
- package/packages/dd-trace/src/appsec/iast/path-line.js +2 -1
- package/packages/dd-trace/src/appsec/stack_trace.js +3 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +3 -2
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +9 -16
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +9 -16
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +9 -14
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +9 -16
- package/packages/dd-trace/src/config/defaults.js +4 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +6 -0
- package/packages/dd-trace/src/config/index.js +140 -39
- package/packages/dd-trace/src/config/parsers.js +9 -1
- package/packages/dd-trace/src/config/supported-configurations.json +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +6 -5
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -5
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +4 -6
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +16 -0
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +25 -6
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +4 -4
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/llmobs/agent-manifest.js +19 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +4 -0
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +8 -4
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +5 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +9 -1
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +17 -5
- package/packages/dd-trace/src/llmobs/span_processor.js +222 -12
- package/packages/dd-trace/src/llmobs/tagger.js +21 -8
- package/packages/dd-trace/src/llmobs/util.js +10 -4
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/writer.js +7 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +64 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +18 -2
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +39 -13
- package/packages/dd-trace/src/openfeature/index.js +6 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +62 -27
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/openfeature/writers/util.js +4 -4
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +18 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/tracer.js +9 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +47 -21
- package/packages/dd-trace/src/plugin_manager.js +1 -2
- package/packages/dd-trace/src/plugins/ci_plugin.js +4 -4
- package/packages/dd-trace/src/plugins/index.js +3 -0
- package/packages/dd-trace/src/plugins/tracing.js +1 -2
- package/packages/dd-trace/src/plugins/util/git.js +102 -40
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +2 -4
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -1
- package/packages/dd-trace/src/plugins/util/test.js +28 -6
- package/packages/dd-trace/src/plugins/util/web.js +106 -20
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/proxy.js +15 -4
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +21 -9
- package/packages/dd-trace/src/span_stats.js +32 -3
- package/packages/dd-trace/src/startup-log.js +2 -1
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/util.js +9 -5
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +8 -8
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/@opentelemetry/resources/LICENSE +0 -201
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -7,7 +7,7 @@ const satisfies = require('../../../vendor/dist/semifies')
|
|
|
7
7
|
const { getDynamicAtrRetryCount } = require('../../dd-trace/src/ci-visibility/dynamic-atr-retries')
|
|
8
8
|
const { EMPTY_EFD_RETRY_POLICY, hasEfdRetries } = require('../../dd-trace/src/ci-visibility/efd-retry-policy')
|
|
9
9
|
const { RUM_TEST_EXECUTION_ID_COOKIE_NAME } = require('../../dd-trace/src/ci-visibility/rum')
|
|
10
|
-
const { getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
|
|
10
|
+
const { getEnvironmentVariable, getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
|
|
11
11
|
const log = require('../../dd-trace/src/log')
|
|
12
12
|
const {
|
|
13
13
|
DYNAMIC_NAME_RE,
|
|
@@ -57,6 +57,14 @@ const VITEST_NO_WORKER_INIT_SETUP_FILE = path.join(
|
|
|
57
57
|
'ci',
|
|
58
58
|
'vitest-no-worker-init-setup.mjs'
|
|
59
59
|
)
|
|
60
|
+
const VITEST_NO_WORKER_INIT_NODE_SETUP_FILE = path.join(
|
|
61
|
+
__dirname,
|
|
62
|
+
'..',
|
|
63
|
+
'..',
|
|
64
|
+
'..',
|
|
65
|
+
'ci',
|
|
66
|
+
'vitest-no-worker-init-node-setup.mjs'
|
|
67
|
+
)
|
|
60
68
|
const VITEST_NO_WORKER_INIT_RUNNER_SETUP_FILE = path.join(
|
|
61
69
|
__dirname,
|
|
62
70
|
'..',
|
|
@@ -73,6 +81,11 @@ const VITEST_NO_WORKER_INIT_V5_SETUP_FILE = path.join(
|
|
|
73
81
|
'ci',
|
|
74
82
|
'vitest-no-worker-init-v5-setup.mjs'
|
|
75
83
|
)
|
|
84
|
+
const VITEST_NO_WORKER_INIT_ENTRYPOINTS = new Set([
|
|
85
|
+
VITEST_NO_WORKER_INIT_NODE_SETUP_FILE,
|
|
86
|
+
VITEST_NO_WORKER_INIT_RUNNER_SETUP_FILE,
|
|
87
|
+
VITEST_NO_WORKER_INIT_V5_SETUP_FILE,
|
|
88
|
+
])
|
|
76
89
|
const VITEST_BROWSER_SETUP_FILE_PLUGIN = {
|
|
77
90
|
name: 'datadog:vitest-browser-setup-file',
|
|
78
91
|
config: configureVitestBrowserSetupFile,
|
|
@@ -412,14 +425,12 @@ function configureWorkerEnv (workerEnv, shouldSkipWorkerInit = false) {
|
|
|
412
425
|
}
|
|
413
426
|
|
|
414
427
|
workerEnv[VITEST_NO_WORKER_INIT_ACTIVE_ENV] = '1'
|
|
415
|
-
|
|
428
|
+
// Pool env objects omit inherited variables; retain the parent's non-Datadog options.
|
|
429
|
+
const inheritedNodeOptions = workerEnv.NODE_OPTIONS ?? getEnvironmentVariable('NODE_OPTIONS')
|
|
430
|
+
rememberDatadogTestOptimizationNodeOptions(inheritedNodeOptions)
|
|
416
431
|
|
|
417
|
-
const nodeOptions = removeDatadogTestOptimizationNodeOptions(
|
|
418
|
-
if (nodeOptions)
|
|
419
|
-
workerEnv.NODE_OPTIONS = nodeOptions
|
|
420
|
-
} else {
|
|
421
|
-
delete workerEnv.NODE_OPTIONS
|
|
422
|
-
}
|
|
432
|
+
const nodeOptions = removeDatadogTestOptimizationNodeOptions(inheritedNodeOptions)
|
|
433
|
+
if (nodeOptions !== undefined) workerEnv.NODE_OPTIONS = nodeOptions
|
|
423
434
|
return workerEnv
|
|
424
435
|
}
|
|
425
436
|
|
|
@@ -438,12 +449,11 @@ function restoreDatadogTestOptimizationNodeOptions (workerEnv) {
|
|
|
438
449
|
}
|
|
439
450
|
}
|
|
440
451
|
|
|
441
|
-
function addSetupFileToVitestConfigs (ctx,
|
|
452
|
+
function addSetupFileToVitestConfigs (ctx, browserSetupFile, testSpecifications) {
|
|
442
453
|
const configs = getNoWorkerInitVitestConfigs(ctx, testSpecifications)
|
|
443
454
|
|
|
444
|
-
for (const config of configs) {
|
|
445
|
-
|
|
446
|
-
|
|
455
|
+
for (const [config, isBrowserMode] of configs) {
|
|
456
|
+
const setupFile = isBrowserMode ? browserSetupFile : VITEST_NO_WORKER_INIT_NODE_SETUP_FILE
|
|
447
457
|
config.includeTaskLocation = true
|
|
448
458
|
if (config.setupFiles === undefined) {
|
|
449
459
|
config.setupFiles = []
|
|
@@ -451,14 +461,28 @@ function addSetupFileToVitestConfigs (ctx, setupFile, testSpecifications) {
|
|
|
451
461
|
config.setupFiles = [config.setupFiles]
|
|
452
462
|
}
|
|
453
463
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (setupFileIndex > 0) {
|
|
457
|
-
config.setupFiles.splice(setupFileIndex, 1)
|
|
458
|
-
}
|
|
459
|
-
config.setupFiles.unshift(setupFile)
|
|
464
|
+
for (let index = config.setupFiles.length - 1; index >= 0; index--) {
|
|
465
|
+
if (VITEST_NO_WORKER_INIT_ENTRYPOINTS.has(config.setupFiles[index])) config.setupFiles.splice(index, 1)
|
|
460
466
|
}
|
|
467
|
+
config.setupFiles.unshift(setupFile)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Makes the annotation helper available to browser setup before Vitest creates its Vite server.
|
|
473
|
+
*
|
|
474
|
+
* @param {{ plugins?: object[] }|undefined} viteOverrides
|
|
475
|
+
*/
|
|
476
|
+
function addBrowserAnnotationPlugin (viteOverrides = {}) {
|
|
477
|
+
if (!viteOverrides.plugins || !Object.isExtensible(viteOverrides) ||
|
|
478
|
+
!Object.isExtensible(viteOverrides.plugins)) {
|
|
479
|
+
viteOverrides = { ...viteOverrides, plugins: [...(viteOverrides.plugins || [])] }
|
|
480
|
+
}
|
|
481
|
+
viteOverrides.plugins ||= []
|
|
482
|
+
if (!viteOverrides.plugins.includes(VITEST_BROWSER_SETUP_FILE_PLUGIN)) {
|
|
483
|
+
viteOverrides.plugins.push(VITEST_BROWSER_SETUP_FILE_PLUGIN)
|
|
461
484
|
}
|
|
485
|
+
return viteOverrides
|
|
462
486
|
}
|
|
463
487
|
|
|
464
488
|
/**
|
|
@@ -501,6 +525,8 @@ function allowVitestBrowserSetupFile (viteConfig) {
|
|
|
501
525
|
VITEST_NO_WORKER_INIT_SETUP_FILE,
|
|
502
526
|
VITEST_NO_WORKER_INIT_RUNNER_SETUP_FILE,
|
|
503
527
|
VITEST_NO_WORKER_INIT_V5_SETUP_FILE,
|
|
528
|
+
require.resolve('../../../ci/vitest-no-worker-init-annotations.mjs'),
|
|
529
|
+
require.resolve('../../dd-trace/src/ci-visibility/test-declaration-annotations'),
|
|
504
530
|
]
|
|
505
531
|
for (const setupFile of setupFiles) {
|
|
506
532
|
if (!allow.includes(setupFile)) {
|
|
@@ -562,31 +588,32 @@ function addVitestBrowserCommand (config) {
|
|
|
562
588
|
}
|
|
563
589
|
|
|
564
590
|
function getNoWorkerInitVitestConfigs (ctx, testSpecifications) {
|
|
565
|
-
const configs = new
|
|
591
|
+
const configs = new Map()
|
|
592
|
+
let fallbackIsBrowserMode
|
|
566
593
|
if (Array.isArray(testSpecifications)) {
|
|
567
|
-
let shouldAddRootConfig = false
|
|
568
594
|
for (const testSpecification of testSpecifications) {
|
|
569
595
|
const project = getTestSpecificationProject(testSpecification)
|
|
570
596
|
const config = safeConfig(project)
|
|
597
|
+
const isBrowserMode = isBrowserTestSpecification(testSpecification)
|
|
571
598
|
if (config) {
|
|
572
|
-
addNoWorkerInitConfig(configs, config)
|
|
599
|
+
addNoWorkerInitConfig(configs, config, isBrowserMode)
|
|
573
600
|
} else {
|
|
574
|
-
|
|
601
|
+
fallbackIsBrowserMode ||= isBrowserMode
|
|
575
602
|
}
|
|
576
603
|
}
|
|
577
604
|
|
|
578
|
-
if (
|
|
605
|
+
if (fallbackIsBrowserMode === undefined && configs.size > 0) {
|
|
579
606
|
return configs
|
|
580
607
|
}
|
|
581
608
|
}
|
|
582
609
|
|
|
583
|
-
addNoWorkerInitConfig(configs, safeConfig(ctx))
|
|
584
|
-
addNoWorkerInitConfig(configs, safeConfig(safeWorkspaceProject(ctx)))
|
|
610
|
+
addNoWorkerInitConfig(configs, safeConfig(ctx), fallbackIsBrowserMode)
|
|
611
|
+
addNoWorkerInitConfig(configs, safeConfig(safeWorkspaceProject(ctx)), fallbackIsBrowserMode)
|
|
585
612
|
return configs
|
|
586
613
|
}
|
|
587
614
|
|
|
588
|
-
function addNoWorkerInitConfig (configs, config) {
|
|
589
|
-
if (config) configs.
|
|
615
|
+
function addNoWorkerInitConfig (configs, config, isBrowserMode = config?.browser?.enabled === true) {
|
|
616
|
+
if (config && !configs.has(config)) configs.set(config, isBrowserMode)
|
|
590
617
|
}
|
|
591
618
|
|
|
592
619
|
function getSelectedTestManagementTests (testManagementTestsBySuite, propertyName) {
|
|
@@ -919,7 +946,8 @@ function createMainProcessReporter (reporterState) {
|
|
|
919
946
|
)
|
|
920
947
|
const knownTests = testProperties?.knownTests
|
|
921
948
|
const testManagementProperties = testProperties?.testManagementTests?.[testName] || {}
|
|
922
|
-
const
|
|
949
|
+
const annotations = task.meta?.__ddTestOptAnnotations || {}
|
|
950
|
+
const isAttemptToFix = testManagementProperties.isAttemptToFix && !annotations.noAutoRetry
|
|
923
951
|
const isNew = !!(
|
|
924
952
|
!isAttemptToFix &&
|
|
925
953
|
state.isKnownTestsEnabled &&
|
|
@@ -929,19 +957,23 @@ function createMainProcessReporter (reporterState) {
|
|
|
929
957
|
)
|
|
930
958
|
const isModified = testProperties?.isModified === true
|
|
931
959
|
const { flakyTestRetriesConfiguration } = testOptimizationData
|
|
932
|
-
const isFlakyTestRetries = !!flakyTestRetriesConfiguration &&
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
960
|
+
const isFlakyTestRetries = !annotations.noAutoRetry && !!flakyTestRetriesConfiguration &&
|
|
961
|
+
isFlakyTestRetriesEnabledForTask({
|
|
962
|
+
isFlakyTestRetriesEnabled: state.isFlakyTestRetriesEnabled,
|
|
963
|
+
isDynamicAtrEnabled: state.isDynamicAtrEnabled,
|
|
964
|
+
flakyTestRetriesIncludesUnnamedProject: flakyTestRetriesConfiguration.includesUnnamedProject,
|
|
965
|
+
flakyTestRetriesProjectNames: flakyTestRetriesConfiguration.projectNames,
|
|
966
|
+
flakyTestRetriesUseRetryMarker: flakyTestRetriesConfiguration.usesRetryMarker,
|
|
967
|
+
}, task)
|
|
938
968
|
|
|
939
969
|
return {
|
|
940
970
|
isAttemptToFix,
|
|
941
|
-
|
|
971
|
+
annotations,
|
|
972
|
+
assignedProperties: testManagementProperties,
|
|
973
|
+
isDisabled: testManagementProperties.isDisabled && !annotations.mustFail,
|
|
942
974
|
isEarlyFlakeDetection: task.meta?.__ddTestOptEfdRetries !== undefined,
|
|
943
975
|
isFlakyTestRetries,
|
|
944
|
-
isQuarantined: testManagementProperties.isQuarantined,
|
|
976
|
+
isQuarantined: testManagementProperties.isQuarantined && !annotations.mustFail,
|
|
945
977
|
isModified,
|
|
946
978
|
isNew,
|
|
947
979
|
testSuite,
|
|
@@ -1282,12 +1314,13 @@ function reportFinalTestAttempt (testReport) {
|
|
|
1282
1314
|
} = getRumCorrelation(task, attemptIndex)
|
|
1283
1315
|
testSkipCh.publish({
|
|
1284
1316
|
...browserEnvironment,
|
|
1317
|
+
annotations: testProperties.annotations,
|
|
1285
1318
|
testName,
|
|
1286
1319
|
testSuiteAbsolutePath,
|
|
1287
1320
|
isNew: testProperties.isNew,
|
|
1288
|
-
isAttemptToFix: testProperties.isAttemptToFix,
|
|
1289
|
-
isDisabled: testProperties.isDisabled,
|
|
1290
|
-
isQuarantined: testProperties.isQuarantined,
|
|
1321
|
+
isAttemptToFix: testProperties.assignedProperties.isAttemptToFix,
|
|
1322
|
+
isDisabled: testProperties.assignedProperties.isDisabled,
|
|
1323
|
+
isQuarantined: testProperties.assignedProperties.isQuarantined,
|
|
1291
1324
|
isRumActive,
|
|
1292
1325
|
isTestFrameworkWorker: true,
|
|
1293
1326
|
requestErrorTags: state.requestErrorTags,
|
|
@@ -1368,9 +1401,10 @@ function reportTestAttempt (testReport, attempt) {
|
|
|
1368
1401
|
isRetry: attempt.isRetry,
|
|
1369
1402
|
isNew: testProperties.isNew,
|
|
1370
1403
|
hasDynamicName: testProperties.hasDynamicName,
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1404
|
+
annotations: testProperties.annotations,
|
|
1405
|
+
isAttemptToFix: testProperties.assignedProperties.isAttemptToFix,
|
|
1406
|
+
isDisabled: testProperties.assignedProperties.isDisabled,
|
|
1407
|
+
isQuarantined: testProperties.assignedProperties.isQuarantined,
|
|
1374
1408
|
isModified: testProperties.isModified,
|
|
1375
1409
|
isRetryReasonEfd: attempt.isRetryReasonEfd,
|
|
1376
1410
|
isRetryReasonAttemptToFix: testProperties.isAttemptToFix && attempt.isRetry,
|
|
@@ -1606,9 +1640,9 @@ function splitNodeOptions (nodeOptions) {
|
|
|
1606
1640
|
const char = nodeOptions[index]
|
|
1607
1641
|
|
|
1608
1642
|
if (quote) {
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
index
|
|
1643
|
+
// Node treats a backslash inside double quotes as escaping the next character.
|
|
1644
|
+
if (char === '\\' && index + 1 < nodeOptions.length) {
|
|
1645
|
+
token += nodeOptions[++index]
|
|
1612
1646
|
continue
|
|
1613
1647
|
}
|
|
1614
1648
|
|
|
@@ -1620,7 +1654,8 @@ function splitNodeOptions (nodeOptions) {
|
|
|
1620
1654
|
continue
|
|
1621
1655
|
}
|
|
1622
1656
|
|
|
1623
|
-
|
|
1657
|
+
// NODE_OPTIONS uses double quotes for grouping; apostrophes belong to option values.
|
|
1658
|
+
if (char === '"') {
|
|
1624
1659
|
quote = char
|
|
1625
1660
|
continue
|
|
1626
1661
|
}
|
|
@@ -1648,7 +1683,8 @@ function serializeNodeOptions (tokens) {
|
|
|
1648
1683
|
for (const token of tokens) {
|
|
1649
1684
|
if (hasSerializedToken) serializedTokens += ' '
|
|
1650
1685
|
if (NODE_OPTIONS_QUOTE_RE.test(token)) {
|
|
1651
|
-
|
|
1686
|
+
// Escape only Node's grouping syntax; JSON would turn literal whitespace into escape letters.
|
|
1687
|
+
serializedTokens += `"${token.replaceAll('\\', '\\\\').replaceAll('"', String.raw`\"`)}"`
|
|
1652
1688
|
} else {
|
|
1653
1689
|
serializedTokens += token
|
|
1654
1690
|
}
|
|
@@ -1867,6 +1903,7 @@ function safeWorkspaceProject (ctx) {
|
|
|
1867
1903
|
}
|
|
1868
1904
|
|
|
1869
1905
|
module.exports = {
|
|
1906
|
+
addBrowserAnnotationPlugin,
|
|
1870
1907
|
configure,
|
|
1871
1908
|
deactivate,
|
|
1872
1909
|
configureWorkerEnv,
|
|
@@ -680,6 +680,7 @@ function resetMainProcessProvidedContext (ctx) {
|
|
|
680
680
|
_ddIsEfdSuiteAdmissionEnabled: false,
|
|
681
681
|
_ddIsFlakyTestRetriesEnabled: false,
|
|
682
682
|
_ddFlakyTestRetriesCount: 0,
|
|
683
|
+
_ddFlakyTestRetriesUseRetryMarker: false,
|
|
683
684
|
_ddIsDynamicAtrEnabled: false,
|
|
684
685
|
_ddDynamicAtrBuckets: undefined,
|
|
685
686
|
_ddFlakyTestRetriesIncludesUnnamedProject: false,
|
|
@@ -823,7 +824,7 @@ async function runMainProcessSetup (
|
|
|
823
824
|
}
|
|
824
825
|
}
|
|
825
826
|
|
|
826
|
-
const flakyTestRetriesConfiguration = configureFlakyTestRetries(ctx, testSpecifications)
|
|
827
|
+
const flakyTestRetriesConfiguration = configureFlakyTestRetries(ctx, testSpecifications, frameworkVersion)
|
|
827
828
|
if (flakyTestRetriesConfiguration) {
|
|
828
829
|
setProvidedContext(ctx, {
|
|
829
830
|
_ddIsFlakyTestRetriesEnabled: isFlakyTestRetriesEnabled,
|
|
@@ -832,6 +833,7 @@ async function runMainProcessSetup (
|
|
|
832
833
|
_ddDynamicAtrBuckets: dynamicAtrBuckets,
|
|
833
834
|
_ddFlakyTestRetriesIncludesUnnamedProject: flakyTestRetriesConfiguration.includesUnnamedProject,
|
|
834
835
|
_ddFlakyTestRetriesProjectNames: flakyTestRetriesConfiguration.projectNames,
|
|
836
|
+
_ddFlakyTestRetriesUseRetryMarker: flakyTestRetriesConfiguration.usesRetryMarker,
|
|
835
837
|
}, 'Could not send library configuration to workers.')
|
|
836
838
|
}
|
|
837
839
|
|
|
@@ -1038,7 +1040,7 @@ function shouldUseBrowserReporter (frameworkVersion, testSpecifications) {
|
|
|
1038
1040
|
testSpecifications.some(isBrowserTestSpecification)
|
|
1039
1041
|
}
|
|
1040
1042
|
|
|
1041
|
-
function configureFlakyTestRetries (ctx, testSpecifications) {
|
|
1043
|
+
function configureFlakyTestRetries (ctx, testSpecifications, frameworkVersion) {
|
|
1042
1044
|
if (!isFlakyTestRetriesEnabled || (!isDynamicAtrEnabled && flakyTestRetriesCount <= 0)) return
|
|
1043
1045
|
|
|
1044
1046
|
const maximumDynamicAtrRetries = dynamicAtrBuckets
|
|
@@ -1047,13 +1049,23 @@ function configureFlakyTestRetries (ctx, testSpecifications) {
|
|
|
1047
1049
|
const retryCount = isDynamicAtrEnabled
|
|
1048
1050
|
? Math.max(1, maximumDynamicAtrRetries)
|
|
1049
1051
|
: flakyTestRetriesCount
|
|
1052
|
+
const usesRetryMarker = isDynamicAtrEnabled || satisfies(frameworkVersion, '>=4.1.0')
|
|
1050
1053
|
let configured = false
|
|
1051
1054
|
let includesUnnamedProject = false
|
|
1052
1055
|
const projectNames = []
|
|
1053
1056
|
for (const { config, projectName } of getVitestProjectConfigs(ctx, testSpecifications)) {
|
|
1054
1057
|
if (!config.retry || config.retry.__ddTestOptAtr) {
|
|
1058
|
+
// Tag retries are resolved during declaration, after the callback's own options were captured.
|
|
1059
|
+
if (config.tags) {
|
|
1060
|
+
config.tags = config.tags.map(tag => tag.retry === undefined
|
|
1061
|
+
? tag
|
|
1062
|
+
: {
|
|
1063
|
+
...tag,
|
|
1064
|
+
meta: { ...tag.meta, __ddTestOptHasFrameworkRetry: true },
|
|
1065
|
+
})
|
|
1066
|
+
}
|
|
1055
1067
|
// The serializable marker survives task inheritance and setup refreshes, unlike numeric retry counts.
|
|
1056
|
-
config.retry =
|
|
1068
|
+
config.retry = usesRetryMarker ? { count: retryCount, __ddTestOptAtr: true } : retryCount
|
|
1057
1069
|
configured = true
|
|
1058
1070
|
if (projectName) {
|
|
1059
1071
|
projectNames.push(projectName)
|
|
@@ -1068,6 +1080,7 @@ function configureFlakyTestRetries (ctx, testSpecifications) {
|
|
|
1068
1080
|
return {
|
|
1069
1081
|
includesUnnamedProject,
|
|
1070
1082
|
projectNames,
|
|
1083
|
+
usesRetryMarker,
|
|
1071
1084
|
}
|
|
1072
1085
|
}
|
|
1073
1086
|
|
|
@@ -1276,6 +1289,13 @@ function getFinishWrapper (exitOrClose) {
|
|
|
1276
1289
|
function getCliOrStartVitestWrapper (frameworkVersion) {
|
|
1277
1290
|
return function (oldCliOrStartVitest) {
|
|
1278
1291
|
return function (...args) {
|
|
1292
|
+
const entrypoint = oldCliOrStartVitest.name
|
|
1293
|
+
if (testSessionStartCh.hasSubscribers && (entrypoint === 'createVitest' || entrypoint === 'startVitest')) {
|
|
1294
|
+
const isCreate = entrypoint === 'createVitest'
|
|
1295
|
+
const isLegacySignature = typeof args[0] === 'string'
|
|
1296
|
+
const overridesIndex = isCreate ? (isLegacySignature ? 2 : 1) : (isLegacySignature ? 3 : 2)
|
|
1297
|
+
args[overridesIndex] = noWorkerInit.addBrowserAnnotationPlugin(args[overridesIndex])
|
|
1298
|
+
}
|
|
1279
1299
|
if (!testSessionStartCh.hasSubscribers || isSessionStarted) {
|
|
1280
1300
|
return oldCliOrStartVitest.apply(this, args)
|
|
1281
1301
|
}
|
|
@@ -2074,6 +2094,16 @@ function getStartVitestWrapper (cliApiPackage, frameworkVersion) {
|
|
|
2074
2094
|
if (createVitestExport) {
|
|
2075
2095
|
shimmer.wrap(cliApiPackage, createVitestExport.key, getCliOrStartVitestWrapper(frameworkVersion))
|
|
2076
2096
|
}
|
|
2097
|
+
// Newer CLI chunks call the bundled namespace instead of the direct function exports.
|
|
2098
|
+
for (const [key, value] of Object.entries(cliApiPackage)) {
|
|
2099
|
+
if (value && typeof value === 'object' && typeof value.startVitest === 'function') {
|
|
2100
|
+
cliApiPackage[key] = {
|
|
2101
|
+
...value,
|
|
2102
|
+
startVitest: cliApiPackage[startVitestExport.key],
|
|
2103
|
+
}
|
|
2104
|
+
if (createVitestExport) cliApiPackage[key].createVitest = cliApiPackage[createVitestExport.key]
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2077
2107
|
wrapMessagePortOn()
|
|
2078
2108
|
|
|
2079
2109
|
wrapVitestInternals(cliApiPackage, frameworkVersion)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { wrapDeclaration } = require('../../dd-trace/src/ci-visibility/test-declaration-annotations')
|
|
4
|
+
const { addHook } = require('./helpers/instrument')
|
|
5
|
+
const { findExportByName, testSessionStartCh } = require('./vitest-util')
|
|
6
|
+
|
|
7
|
+
/** @param {Record<string, unknown>} pkg */
|
|
8
|
+
function captureDeclarations (pkg) {
|
|
9
|
+
if (!testSessionStartCh.hasSubscribers) return pkg
|
|
10
|
+
const getCurrentSuite = findExportByName(pkg, 'getCurrentSuite')?.value
|
|
11
|
+
if (!getCurrentSuite) return pkg
|
|
12
|
+
for (const [name, value] of Object.entries(pkg)) {
|
|
13
|
+
if (typeof value !== 'function' || !('each' in value)) continue
|
|
14
|
+
pkg[name] = wrapDeclaration(value, getCurrentSuite)
|
|
15
|
+
}
|
|
16
|
+
return pkg
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
addHook({ name: '@vitest/runner', versions: ['>=1.6.0 <5.0.0'] }, captureDeclarations)
|
|
20
|
+
addHook({ name: 'vitest', versions: ['>=5.0.0'], filePattern: 'dist/chunks/run.*' }, captureDeclarations)
|
|
@@ -182,6 +182,7 @@ function getProvidedContext () {
|
|
|
182
182
|
_ddDynamicAtrBuckets: dynamicAtrBuckets,
|
|
183
183
|
_ddFlakyTestRetriesIncludesUnnamedProject: flakyTestRetriesIncludesUnnamedProject,
|
|
184
184
|
_ddFlakyTestRetriesProjectNames: flakyTestRetriesProjectNames,
|
|
185
|
+
_ddFlakyTestRetriesUseRetryMarker: flakyTestRetriesUseRetryMarker,
|
|
185
186
|
_ddIsImpactedTestsEnabled: isImpactedTestsEnabled,
|
|
186
187
|
_ddTestSessionId: testSessionId,
|
|
187
188
|
_ddTestModuleId: testModuleId,
|
|
@@ -211,6 +212,7 @@ function getProvidedContext () {
|
|
|
211
212
|
dynamicAtrBuckets,
|
|
212
213
|
flakyTestRetriesIncludesUnnamedProject,
|
|
213
214
|
flakyTestRetriesProjectNames,
|
|
215
|
+
flakyTestRetriesUseRetryMarker,
|
|
214
216
|
isImpactedTestsEnabled,
|
|
215
217
|
testSessionId,
|
|
216
218
|
testModuleId,
|
|
@@ -254,8 +256,9 @@ function getProvidedContext () {
|
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
function isFlakyTestRetriesEnabledForTask (providedContext, task) {
|
|
257
|
-
if (!providedContext.isFlakyTestRetriesEnabled) return false
|
|
258
|
-
if (providedContext.isDynamicAtrEnabled
|
|
259
|
+
if (!providedContext.isFlakyTestRetriesEnabled || task.meta?.__ddTestOptNativeRetry) return false
|
|
260
|
+
if ((providedContext.isDynamicAtrEnabled || providedContext.flakyTestRetriesUseRetryMarker) &&
|
|
261
|
+
!task.retry?.__ddTestOptAtr) return false
|
|
259
262
|
|
|
260
263
|
const { flakyTestRetriesProjectNames } = providedContext
|
|
261
264
|
if (!Array.isArray(flakyTestRetriesProjectNames)) return true
|
|
@@ -46,6 +46,26 @@ const {
|
|
|
46
46
|
getVitestTestProperties,
|
|
47
47
|
} = require('./vitest-util')
|
|
48
48
|
|
|
49
|
+
const emptyAnnotations = { mustFail: false, noAutoRetry: false }
|
|
50
|
+
|
|
51
|
+
/** @param {object} task */
|
|
52
|
+
function getAnnotations (task) {
|
|
53
|
+
return task.meta?.__ddTestOptAnnotations || emptyAnnotations
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** @param {object} task */
|
|
57
|
+
function getReportedProperties (task) {
|
|
58
|
+
const properties = taskToTestProperties.get(task) || getVitestTestProperties(
|
|
59
|
+
getProvidedContext(), task.file.filepath, getTestName(task)
|
|
60
|
+
)
|
|
61
|
+
return {
|
|
62
|
+
isAttemptToFix: properties.isAttemptToFix,
|
|
63
|
+
isDisabled: properties.isDisabled,
|
|
64
|
+
isQuarantined: properties.isQuarantined,
|
|
65
|
+
annotations: getAnnotations(task),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
49
69
|
const EFD_SUITE_ADMISSION_TIMEOUT_MS = 5000
|
|
50
70
|
const logSubmissionFlushCh = channel('ci:log-submission:flush')
|
|
51
71
|
const wrappedTestRunners = new WeakSet()
|
|
@@ -382,10 +402,11 @@ function hasConcurrentTests (file) {
|
|
|
382
402
|
*/
|
|
383
403
|
function hasRunnableNewTest (file, providedContext) {
|
|
384
404
|
for (const task of getTypeTasks(file.tasks)) {
|
|
385
|
-
if (task.mode === 'skip' || task.mode === 'todo') continue
|
|
405
|
+
if (task.mode === 'skip' || task.mode === 'todo' || getAnnotations(task).noAutoRetry) continue
|
|
386
406
|
|
|
387
407
|
const testProperties = getVitestTestProperties(providedContext, file.filepath, getTestName(task))
|
|
388
|
-
if (testProperties.isNew && !testProperties.isAttemptToFix &&
|
|
408
|
+
if (testProperties.isNew && !testProperties.isAttemptToFix &&
|
|
409
|
+
(!testProperties.isDisabled || getAnnotations(task).mustFail)) {
|
|
389
410
|
return true
|
|
390
411
|
}
|
|
391
412
|
}
|
|
@@ -550,6 +571,11 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
550
571
|
} = providedContext
|
|
551
572
|
const testProperties = getVitestTestProperties(providedContext, task.file.filepath, testName)
|
|
552
573
|
taskToTestProperties.set(task, testProperties)
|
|
574
|
+
const annotations = getAnnotations(task)
|
|
575
|
+
if (annotations.noAutoRetry && !annotations.hasFrameworkRetry &&
|
|
576
|
+
isFlakyTestRetriesEnabledForTask(providedContext, task)) {
|
|
577
|
+
task.retry = 0
|
|
578
|
+
}
|
|
553
579
|
|
|
554
580
|
if (isTestManagementTestsEnabled) {
|
|
555
581
|
const {
|
|
@@ -557,7 +583,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
557
583
|
isDisabled,
|
|
558
584
|
isQuarantined,
|
|
559
585
|
} = testProperties
|
|
560
|
-
if (isAttemptToFix) {
|
|
586
|
+
if (isAttemptToFix && !annotations.noAutoRetry) {
|
|
561
587
|
if (task.repeats !== testManagementAttemptToFixRetries) {
|
|
562
588
|
attemptToFixRetryTasks.add(task)
|
|
563
589
|
}
|
|
@@ -566,10 +592,10 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
566
592
|
attemptToFixTasks.add(task)
|
|
567
593
|
attemptToFixTaskToStatuses.set(task, [])
|
|
568
594
|
}
|
|
569
|
-
if (isQuarantined) {
|
|
595
|
+
if (isQuarantined && !annotations.mustFail) {
|
|
570
596
|
quarantinedTasks.add(task)
|
|
571
597
|
}
|
|
572
|
-
if (isDisabled) {
|
|
598
|
+
if (isDisabled && !annotations.mustFail) {
|
|
573
599
|
disabledTasks.add(task)
|
|
574
600
|
if (!attemptToFixTasks.has(task)) {
|
|
575
601
|
// we only actually skip if the test is not being attempted to be fixed
|
|
@@ -589,7 +615,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
589
615
|
}
|
|
590
616
|
}
|
|
591
617
|
|
|
592
|
-
const isEfdCandidate = isEarlyFlakeDetectionEnabled &&
|
|
618
|
+
const isEfdCandidate = !annotations.noAutoRetry && isEarlyFlakeDetectionEnabled &&
|
|
593
619
|
!attemptToFixTasks.has(task) &&
|
|
594
620
|
!disabledTasks.has(task) &&
|
|
595
621
|
(modifiedTasks.has(task) || newTasks.has(task))
|
|
@@ -605,6 +631,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
605
631
|
}
|
|
606
632
|
|
|
607
633
|
if (
|
|
634
|
+
!annotations.noAutoRetry &&
|
|
608
635
|
providedContext.isDynamicAtrEnabled &&
|
|
609
636
|
isFlakyTestRetriesEnabledForTask(providedContext, task) &&
|
|
610
637
|
!attemptToFixTasks.has(task) &&
|
|
@@ -818,7 +845,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
818
845
|
}
|
|
819
846
|
}
|
|
820
847
|
|
|
821
|
-
const isRetryReasonAtr = numAttempt > 0 &&
|
|
848
|
+
const isRetryReasonAtr = !getAnnotations(task).noAutoRetry && numAttempt > 0 &&
|
|
822
849
|
isFlakyTestRetriesEnabledForTask(providedContext, task) &&
|
|
823
850
|
!attemptToFixRetryTasks.has(task) &&
|
|
824
851
|
!efdRetryTasks.has(task)
|
|
@@ -832,9 +859,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
832
859
|
isNew,
|
|
833
860
|
hasDynamicName: dynamicNameTasks.has(task),
|
|
834
861
|
mightHitProbe: isDiEnabled && isFailedTestReplayAllowed && numAttempt > 0,
|
|
835
|
-
|
|
836
|
-
isDisabled: disabledTasks.has(task),
|
|
837
|
-
isQuarantined: quarantinedTasks.has(task),
|
|
862
|
+
...getReportedProperties(task),
|
|
838
863
|
isRetryReasonAtr,
|
|
839
864
|
isModified: modifiedTasks.has(task),
|
|
840
865
|
}
|
|
@@ -1123,9 +1148,7 @@ function getStartTestsWrapper (frameworkVersion) {
|
|
|
1123
1148
|
testName: getTestName(task),
|
|
1124
1149
|
testSuiteAbsolutePath: task.file.filepath,
|
|
1125
1150
|
isNew: newTasks.has(task),
|
|
1126
|
-
|
|
1127
|
-
isDisabled: disabledTasks.has(task),
|
|
1128
|
-
isQuarantined: quarantinedTasks.has(task),
|
|
1151
|
+
...getReportedProperties(task),
|
|
1129
1152
|
})
|
|
1130
1153
|
} else if ((state === 'pass' && !isSwitchedStatus) || switchedStatus === 'pass') {
|
|
1131
1154
|
// Attempt-to-fix can pass its last attempt while an earlier failure still fails the suite.
|
|
@@ -1174,7 +1197,8 @@ function getStartTestsWrapper (frameworkVersion) {
|
|
|
1174
1197
|
}
|
|
1175
1198
|
|
|
1176
1199
|
// ATR: set hasFailedAllRetries when all auto test retries were exhausted and every attempt failed
|
|
1177
|
-
const isAtrRetry =
|
|
1200
|
+
const isAtrRetry = !getAnnotations(task).noAutoRetry &&
|
|
1201
|
+
isFlakyTestRetriesEnabledForTask(providedContext, task) && !attemptToFixTasks.has(task) &&
|
|
1178
1202
|
!efdRetryTasks.has(task)
|
|
1179
1203
|
if (isAtrRetry) {
|
|
1180
1204
|
// Dynamic ATR: use the per-test duration-based count instead of the flat limit.
|
|
@@ -1230,9 +1254,7 @@ function getStartTestsWrapper (frameworkVersion) {
|
|
|
1230
1254
|
testName: getTestName(task),
|
|
1231
1255
|
testSuiteAbsolutePath: task.file.filepath,
|
|
1232
1256
|
isNew: newTasks.has(task),
|
|
1233
|
-
|
|
1234
|
-
isDisabled: disabledTasks.has(task),
|
|
1235
|
-
isQuarantined: quarantinedTasks.has(task),
|
|
1257
|
+
...getReportedProperties(task),
|
|
1236
1258
|
})
|
|
1237
1259
|
}
|
|
1238
1260
|
}
|
|
@@ -3,14 +3,24 @@
|
|
|
3
3
|
const { getEnvironmentVariable } = require('../../dd-trace/src/config/helper')
|
|
4
4
|
const { isTrue } = require('../../dd-trace/src/util')
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const isWorker = getEnvironmentVariable('DD_VITEST_WORKER') === '1'
|
|
7
|
+
const VITEST_NO_WORKER_INIT_ACTIVE_ENV = 'DD_TEST_OPT_VITEST_NO_WORKER_INIT_ACTIVE'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (isTrue(process.env[VITEST_NO_WORKER_INIT_ACTIVE_ENV])) return
|
|
9
|
+
// No-worker setup captures declarations directly, without registering instrumentation hooks.
|
|
10
|
+
// eslint-disable-next-line eslint-rules/eslint-process-env
|
|
11
|
+
if (isWorker && isTrue(process.env[VITEST_NO_WORKER_INIT_ACTIVE_ENV])) return
|
|
13
12
|
|
|
13
|
+
const { channel } = require('./helpers/instrument')
|
|
14
|
+
require('./vitest-test-annotations')
|
|
15
|
+
|
|
16
|
+
channel('tracing:orchestrion:@vitest/runner:createTestTask:end').subscribe(({ arguments: args, result: task }) => {
|
|
17
|
+
// Suite options have already been merged here, including overrides equal to ATR's count.
|
|
18
|
+
if (args[1]?.retry !== undefined && task?.meta) {
|
|
19
|
+
task.meta = { ...task.meta, __ddTestOptNativeRetry: true }
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
if (isWorker) {
|
|
14
24
|
require('./vitest-worker')
|
|
15
25
|
} else {
|
|
16
26
|
require('./vitest-main')
|
|
@@ -250,6 +250,11 @@ class CucumberPlugin extends CiPlugin {
|
|
|
250
250
|
[TEST_SOURCE_START]: testSourceLine,
|
|
251
251
|
[TEST_SOURCE_FILE]: testSourceFile,
|
|
252
252
|
}
|
|
253
|
+
if (ctx.testAnnotations?.mustFail) extraTags['test.test_management.prevent_failure_suppression'] = 'true'
|
|
254
|
+
if (ctx.testAnnotations?.noAutoRetry) extraTags['test.test_management.no_auto_retry'] = 'true'
|
|
255
|
+
if (ctx.assignedProperties?.attempt_to_fix) extraTags[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] = 'true'
|
|
256
|
+
if (ctx.assignedProperties?.disabled) extraTags[TEST_MANAGEMENT_IS_DISABLED] = 'true'
|
|
257
|
+
if (ctx.assignedProperties?.quarantined) extraTags[TEST_MANAGEMENT_IS_QUARANTINED] = 'true'
|
|
253
258
|
if (isParallel) {
|
|
254
259
|
extraTags[CUCUMBER_IS_PARALLEL] = 'true'
|
|
255
260
|
}
|