Repository navigation
Vitest integration: use --vitest-config instead of --command to prevent wrong files selection - #169
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 4b69fe7 | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
More details
The static review raised no reportable concern with the exact-file filtering hook. Supported-version Vitest integration remains unverified locally because dependencies were unavailable.
🤖 Bits Code Review · Commit faf2310 · @DataDog review to ask questions
|
@autotest review |
E2E verification: passedTested by: Shepherd Agent (autonomous QA for Datadog Test Optimization) The original duplicate-file bug is fixed, and the leaked-timer shutdown regression found during the initial review is now fixed. Shepherd playgrounds require migration to the new config-based interface; the migration is prepared in https://github.com/ddoghq/shepherd/pull/154.
Issues and resolutionThe initial revision The new interface rejects the old Telemetry verification and methodologyDatadog UI verification: Production Datadog UI ingestion was not tested. Actual tracer events received by Mockdog were parsed and checked for counts, completion, filenames, and statuses. Validation combined fresh CLI fixtures with exact saved assignments, an uncleared interval and completed async teardown, a bounded external watchdog, separate Mockdog instances for traced pass/fail cases, the adapter/tracing compatibility matrix, and Shepherd's full migrated Vue parallel workload. The PR head was rechecked after testing and still points to the commit above. |
|
@autotest review |
There was a problem hiding this comment.
More details
Exact-path filtering preserves each assigned file’s project/pool specifications while avoiding Vitest’s substring filename matching. Runtime compatibility across supported Vitest versions remains unverified locally because dependencies were unavailable.
🤖 Bits Code Review · Commit 29fc987 · @DataDog review to ask questions
29fc987 to
4b69fe7
Compare
What
Vitest workers now execute only their assigned files through a directly launched Node API adapter. Discovery and execution load the same Vitest config. Vitest 3–5 use the public specification API; a separate module handles Vitest 1.6–2.
The adapter creates a non-watch context, discovers specifications, keeps the exact assigned paths, runs those specifications, and shuts down through Vitest's
exit()API, honoringteardownTimeoutwhen leaked handles remain. It preserves multiple project/pool specifications for an assigned file. The previous CLI interception, adapter preload, argument rewriting, and CLI discovery fallback are removed.Vitest integration changes: install Vitest locally and use
dd-trace5.125.0 or higher.--commandis rejected for Vitest with migration instructions. Put Vitest options in its config and use the new--vitest-config/DD_TEST_OPTIMIZATION_RUNNER_VITEST_CONFIGsetting for a non-default file. Run shell/npm preparation steps before ddtest. The migration guide covers project filters, reporters, coverage, snapshots, Node options, and unsupported CLI workflows.Why
With
test.dir: 'src', the filename filter forsrc/endOfYear/test.tsalso matchessrc/eachWeekendOfYear/test.ts. Disjoint worker assignments can therefore execute a file twice or run a file excluded from the plan.Vitest documents substring filename filtering. Its programmatic lifecycle and specification API let ddtest run exact assignments while Vitest handles projects, setup/teardown, reporters, and coverage. Direct invocation gives this integration an explicit configuration contract. dd-trace-js #10161, released in 5.125.0, instruments
createVitestdirectly.Closes #168.
E2E testing
Prerequisites: check out this branch; use the Go version in
go.mod, Node 22.14.0 or later on PATH, npm, Git, and npm registry access. These scenarios disable tracing and need no Datadog credentials. To verify reporting in Datadog, repeat the passing/failing scenarios in an environment with Test Optimization configured and confirm the assigned tests and completed session appear.Build the binary and prepare an isolated fixture:
Expected: two passing test files under the configured
srcdirectory. Perform the remaining actions inside this fixture.Compare native CLI filtering with exact ddtest execution:
Expected: native Vitest runs both files. DDTest exits zero, records each file exactly once under different worker sessions, and creates one resource file per test without an
EEXISTerror. Saved split files show disjoint assignments. All processes finish after the run.Verify wrapper migration fails clearly, then use the environment config setting:
Expected: nonzero exit with instructions to remove
--commandand use--vitest-config; no test events. Then run:Expected: planning loads the selected config without executing tests; execution records only
endOfYear. Keep this config environment variable set for the following steps.Verify exclusions and assigned failures:
Expected: exit zero and one
endOfYearevent. Change its assertion toexpect(1).toBe(2), clear the saved plan/events, and repeat: expect nonzero exit and still no excluded file execution. Restore the passing assertion.Verify configured project selection and JSON reporting on Vitest 5.0.0:
Expected: one
endOfYearevent and one passing test in the JSON report. Removeproject: ['unit'], clear the plan/events and repeat: expect twoendOfYearevents and two passing tests, one per project, with noeachWeekendOfYearexecution.Verify CI snapshots and configured sharding:
Expected: missing-snapshot failure and no snapshot file, with no watch-mode/sharding error. Clear the saved plan and repeat with
CI=true REPRO_UPDATE=1: expect exit zero andsrc/snapshot/__snapshots__/test.ts.snapcontaining the assigned value.Verify shutdown after completed teardown with a leaked timer:
Expected: the assigned test passes,
QA_TEARDOWN_COMPLETEDappears, and the process exits zero after Vitest's one-second shutdown timeout instead of hanging. Vitest prints its timeout diagnostic because the interval is still active. Change the assertion toexpect(1).toBe(2), clear the plan, and repeat: teardown still completes and shutdown remains bounded, with a nonzero exit. Restore the passing assertion. Repeat both runs with tracing enabled in a configured Test Optimization environment: confirm the assigned test, completed suite, and completed session arrive with the correct pass/fail status.Repeat steps 2–4 and 7 on Vitest 1.6.1, 2.1.9, 3.2.7, and 4.1.11, installing each with
npx --yes npm@11.11.1 install --save-dev vitest@VERSION. Before each version, restore passing assertions, removesrc/snapshot, clear.testoptimizationand event records, and remove.created-endOfYear/.created-eachWeekendOfYear. Expected: exact assignments, config selection, exclusions, failure status, bounded shutdown, and wrapper migration behave the same on every version.Leave the fixture, then remove it and the temporary binary: