Skip to content

refactor(vitest): prepare test metadata in main#9171

Merged
juan-fernandez merged 4 commits into
masterfrom
juan-fernandez/vitest-move-more-to-main
Jul 1, 2026
Merged

refactor(vitest): prepare test metadata in main#9171
juan-fernandez merged 4 commits into
masterfrom
juan-fernandez/vitest-move-more-to-main

Conversation

@juan-fernandez

@juan-fernandez juan-fernandez commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Moves Vitest Test Optimization data preparation from vitest-worker into vitest-main.

vitest-main now builds the per-file metadata that workers need before test execution, including normalized suite paths, known-test names, simplified Test Management properties, impacted-test state from the pull request diff, and the worker environment used by Vitest runs.

vitest-worker consumes that prepared metadata and keeps the behavior that needs live worker state: applying Vitest task retries/skips, preserving active test span context in test functions and hooks, tracking retry/final status, and reporting worker test events.

Programmatic Vitest reruns refresh metadata for the new set of test files and clear stale retry/flaky context between runs.

Motivation

This makes the vitest-main / vitest-worker contract more explicit and keeps worker-side instrumentation focused on behavior that must run with live Vitest task/span state.

@dd-octo-sts

dd-octo-sts Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.44 MB
Deduped: 7.5 MB
No deduping: 7.5 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.2.0 | 104.26 kB | 843.44 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Jul 1, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 84.70%
Overall Coverage: 88.02% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3c74603 | Docs | Datadog PR Page | Give us feedback!

@pr-commenter

pr-commenter Bot commented Jul 1, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-01 14:03:31

Comparing candidate commit 3c74603 in PR branch juan-fernandez/vitest-move-more-to-main with baseline commit 79b87ef in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2257 metrics, 29 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-20

  • unstable execution_time [-192189.199µs; +191321.066µs] or [-5.144%; +5.121%]

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-180.680ms; +188.462ms] or [-6.894%; +7.191%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-209.375ms; +202.863ms] or [-8.369%; +8.109%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-152.705ms; +155.370ms] or [-5.306%; +5.399%]

scenario:appsec-control-20

  • unstable execution_time [-141.121ms; +173.654ms] or [-8.133%; +10.008%]

scenario:appsec-control-24

  • unstable execution_time [-103577.066µs; +104358.566µs] or [-8.518%; +8.583%]

scenario:appsec-control-26

  • unstable execution_time [-113813.413µs; +113145.480µs] or [-9.436%; +9.381%]

scenario:debugger-line-probe-with-snapshot-default-26

  • unstable cpu_user_time [-2125.131ms; +3457.356ms] or [-22.785%; +37.069%]
  • unstable execution_time [-2151.438ms; +3474.513ms] or [-21.476%; +34.683%]
  • unstable instructions [-18.4G instructions; +30.2G instructions] or [-23.811%; +39.005%]
  • unstable max_rss_usage [-6.372MB; +9.865MB] or [-3.992%; +6.181%]
  • unstable throughput [-761.145op/s; +467.772op/s] or [-23.160%; +14.233%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable cpu_user_time [-1.981s; +4.240s] or [-23.328%; +49.917%]
  • unstable execution_time [-2.002s; +4.284s] or [-21.824%; +46.694%]
  • unstable instructions [-16.7G instructions; +35.8G instructions] or [-24.087%; +51.731%]
  • unstable max_rss_usage [-7.004MB; +14.814MB] or [-4.374%; +9.251%]
  • unstable throughput [-1253.361op/s; +589.125op/s] or [-34.134%; +16.044%]

scenario:debugger-line-probe-with-snapshot-minimal-26

  • unstable cpu_user_time [-2.849s; +0.394s] or [-28.698%; +3.966%]
  • unstable execution_time [-2.876s; +0.412s] or [-27.130%; +3.885%]
  • unstable instructions [-25.8G instructions; +3.5G instructions] or [-31.084%; +4.212%]
  • unstable throughput [-98.620op/s; +638.359op/s] or [-3.121%; +20.203%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-1866.564ms; +2952.898ms] or [-23.579%; +37.302%]
  • unstable execution_time [-1878.155ms; +2971.120ms] or [-21.827%; +34.529%]
  • unstable instructions [-15.9G instructions; +25.2G instructions] or [-24.721%; +39.151%]
  • unstable max_rss_usage [-6.177MB; +10.592MB] or [-3.907%; +6.699%]
  • unstable throughput [-879.779op/s; +558.192op/s] or [-22.957%; +14.566%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-376.154ms; +355.814ms] or [-7.709%; +7.292%]
  • unstable execution_time [-375.504ms; +362.745ms] or [-7.581%; +7.324%]
  • unstable throughput [-125248.692op/s; +129099.759op/s] or [-7.379%; +7.606%]

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.19565% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.73%. Comparing base (79b87ef) to head (3c74603).

Files with missing lines Patch % Lines
packages/datadog-plugin-vitest/src/index.js 71.42% 6 Missing ⚠️
...ckages/datadog-instrumentations/src/vitest-main.js 99.17% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9171      +/-   ##
==========================================
+ Coverage   93.71%   93.73%   +0.01%     
==========================================
  Files         895      895              
  Lines       51324    51398      +74     
  Branches    11947    11980      +33     
==========================================
+ Hits        48100    48179      +79     
+ Misses       3224     3219       -5     
Flag Coverage Δ
aiguard 34.87% <ø> (-0.08%) ⬇️
aiguard-integration 41.79% <ø> (ø)
apm-bucket-0 34.84% <ø> (-0.08%) ⬇️
apm-bucket-1 40.33% <ø> (-0.07%) ⬇️
apm-bucket-2 37.34% <ø> (-0.07%) ⬇️
apm-capabilities-tracing 48.69% <0.00%> (+0.01%) ⬆️
apm-integrations-aerospike 33.12% <ø> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript 40.02% <ø> (-0.08%) ⬇️
apm-integrations-couchbase 33.24% <ø> (-0.24%) ⬇️
apm-integrations-http 41.95% <ø> (-0.07%) ⬇️
apm-integrations-kafkajs 40.30% <ø> (-0.04%) ⬇️
apm-integrations-next 29.50% <ø> (-0.04%) ⬇️
apm-integrations-prisma 35.03% <ø> (-0.07%) ⬇️
apm-integrations-tedious 33.89% <ø> (-0.08%) ⬇️
appsec 57.70% <ø> (-0.03%) ⬇️
appsec-express_fastify_graphql 53.67% <ø> (-0.06%) ⬇️
appsec-integration 36.45% <0.78%> (-0.12%) ⬇️
appsec-kafka_ldapjs_lodash 43.59% <ø> (-0.06%) ⬇️
appsec-mongodb-core_mongoose_mysql 48.74% <ø> (-0.06%) ⬇️
appsec-next 28.01% <ø> (-0.06%) ⬇️
appsec-node-serialize_passport_postgres 47.79% <ø> (-0.18%) ⬇️
appsec-sourcing_stripe_template 45.47% <ø> (-0.06%) ⬇️
debugger 44.37% <ø> (-0.05%) ⬇️
instrumentations-bucket-0 28.15% <ø> (-0.08%) ⬇️
instrumentations-bucket-1 37.40% <ø> (-0.07%) ⬇️
instrumentations-bucket-10 40.35% <ø> (-0.07%) ⬇️
instrumentations-bucket-11 27.95% <ø> (-0.08%) ⬇️
instrumentations-bucket-12 28.67% <ø> (-0.08%) ⬇️
instrumentations-bucket-13 27.78% <ø> (-0.08%) ⬇️
instrumentations-bucket-2 30.23% <ø> (-0.07%) ⬇️
instrumentations-bucket-3 35.90% <ø> (-0.07%) ⬇️
instrumentations-bucket-4 28.56% <ø> (-0.08%) ⬇️
instrumentations-bucket-5 36.28% <ø> (-0.07%) ⬇️
instrumentations-bucket-6 38.25% <ø> (-0.08%) ⬇️
instrumentations-bucket-7 36.01% <ø> (-0.07%) ⬇️
instrumentations-bucket-8 36.95% <ø> (-0.07%) ⬇️
instrumentations-bucket-9 39.45% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-couchbase 46.48% <ø> (ø)
instrumentations-integration-esbuild 25.05% <0.78%> (-0.10%) ⬇️
llmobs-ai_anthropic_bedrock 39.53% <ø> (-0.07%) ⬇️
llmobs-google-genai_langchain_vertex-ai 36.97% <ø> (-0.06%) ⬇️
llmobs-openai 39.58% <ø> (-0.07%) ⬇️
llmobs-sdk 43.59% <ø> (-0.08%) ⬇️
master-coverage 93.73% <96.19%> (?)
openfeature 37.76% <ø> (ø)
openfeature-unit 50.39% <ø> (ø)
platform-core_esbuild_instrumentations-misc 23.50% <0.78%> (-0.10%) ⬇️
platform-integration 47.42% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 19.02% <0.78%> (-0.11%) ⬇️
plugins-bucket-0 36.37% <ø> (-0.07%) ⬇️
plugins-bucket-1 39.60% <ø> (ø)
plugins-bucket-11 38.46% <ø> (-0.08%) ⬇️
plugins-bucket-17 39.15% <ø> (-0.07%) ⬇️
plugins-bucket-18 42.01% <ø> (-0.07%) ⬇️
plugins-bucket-19 39.56% <ø> (-0.07%) ⬇️
plugins-bucket-20 43.25% <ø> (-0.07%) ⬇️
plugins-bucket-4 37.71% <ø> (-0.07%) ⬇️
plugins-bullmq_cassandra_cookie 39.76% <ø> (-0.07%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 33.22% <ø> (-0.08%) ⬇️
plugins-fetch_fs_generic-pool 36.05% <ø> (-0.07%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 43.10% <ø> (-0.07%) ⬇️
plugins-hapi_hono_ioredis 37.78% <ø> (-0.07%) ⬇️
plugins-jest_knex_langgraph 32.60% <ø> (-0.08%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 27.85% <ø> (-0.08%) ⬇️
plugins-lodash_mariadb_memcached 35.17% <ø> (-0.08%) ⬇️
plugins-mongodb_mongodb-core_mongoose 36.31% <ø> (-0.07%) ⬇️
plugins-multer_mysql_mysql2 35.14% <ø> (-0.08%) ⬇️
plugins-nats_node-serialize_opensearch 37.09% <ø> (-0.13%) ⬇️
plugins-passport-http_pino_postgres 35.53% <ø> (-0.08%) ⬇️
plugins-process_pug_redis 34.26% <ø> (-0.08%) ⬇️
plugins-undici_url_valkey 35.88% <ø> (+0.05%) ⬆️
plugins-vm_winston_ws 37.55% <ø> (-0.08%) ⬇️
profiling 43.62% <ø> (-0.07%) ⬇️
serverless-aws-sdk-aws-sdk 33.29% <ø> (-0.07%) ⬇️
serverless-aws-sdk-bedrockruntime 32.16% <ø> (-0.07%) ⬇️
serverless-aws-sdk-client 37.16% <ø> (ø)
serverless-aws-sdk-dynamodb 34.22% <ø> (+0.01%) ⬆️
serverless-aws-sdk-eventbridge 27.25% <ø> (-0.07%) ⬇️
serverless-aws-sdk-kinesis 37.40% <ø> (-0.07%) ⬇️
serverless-aws-sdk-lambda 34.59% <ø> (-0.07%) ⬇️
serverless-aws-sdk-s3 ?
serverless-aws-sdk-serverless-peer-service 39.47% <ø> (-0.08%) ⬇️
serverless-aws-sdk-sns 38.25% <ø> (-0.07%) ⬇️
serverless-aws-sdk-sqs 38.00% <ø> (-0.07%) ⬇️
serverless-aws-sdk-stepfunctions 33.18% <ø> (-0.07%) ⬇️
serverless-aws-sdk-util 47.95% <ø> (ø)
serverless-bucket-0 39.46% <ø> (ø)
serverless-lambda 34.33% <ø> (-0.09%) ⬇️
test-optimization-cucumber 52.30% <ø> (+0.11%) ⬆️
test-optimization-cypress 49.41% <ø> (+0.06%) ⬆️
test-optimization-jest 55.37% <ø> (+0.07%) ⬆️
test-optimization-mocha 53.38% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-atr 43.33% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-efd 43.61% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-final-status 43.73% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-impacted-tests 43.16% <ø> (ø)
test-optimization-playwright-playwright-reporting 43.26% <ø> (-0.15%) ⬇️
test-optimization-playwright-playwright-test-management 44.72% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-test-span 44.38% <ø> (-0.06%) ⬇️
test-optimization-selenium 45.26% <ø> (+0.06%) ⬆️
test-optimization-testopt 48.01% <20.10%> (+0.07%) ⬆️
test-optimization-vitest 51.00% <96.19%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/vitest-move-more-to-main branch from 755c87e to aeea03e Compare July 1, 2026 11:13
@juan-fernandez juan-fernandez changed the title refactor(vitest): move test classification to worker context refactor(vitest): prepare test metadata in main Jul 1, 2026
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aeea03e08f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/vitest-main.js
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec032db68b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/vitest-main.js
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71d1a3f6e3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/vitest-main.js
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 3c74603ded

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@juan-fernandez
juan-fernandez marked this pull request as ready for review July 1, 2026 14:07
@juan-fernandez
juan-fernandez requested review from a team as code owners July 1, 2026 14:07
@juan-fernandez
juan-fernandez requested review from bojbrook and removed request for a team July 1, 2026 14:07

@datadog-prod-us1-3 datadog-prod-us1-3 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: PASS

More details

The refactor moves test-classification logic (isNew, isModified, isDisabled, isQuarantined, isAttemptToFix) from a channel-callback model into a pre-computed map built in the main process. 27 adversarial scenarios covering path normalization, property mapping, empty/partial inputs, and specs-key ordering all passed. Behavior is functionally equivalent to the old channel model: workers awaiting ensureMainProcessSetup see the fully-populated _ddTestPropertiesByFilepath before any test runs, and the quarantinedTasks.add call site move from onBeforeTryTask to onBeforeRunTask preserves identical semantics since onBeforeRunTask fires before the first attempt.

Was this helpful? React 👍 or 👎

📊 Validated against 27 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 3c74603 · What is Autotest? · Any feedback? Reach out in #autotest

@juan-fernandez
juan-fernandez merged commit a4a3beb into master Jul 1, 2026
807 checks passed
@juan-fernandez
juan-fernandez deleted the juan-fernandez/vitest-move-more-to-main branch July 1, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants