Skip to content

feat: add Vitest support - #109

Closed
cbasitodx wants to merge 4 commits into
DataDog:mainfrom
cbasitodx:sebas.conde/feat/add_vitest_support
Closed

feat: add Vitest support#109
cbasitodx wants to merge 4 commits into
DataDog:mainfrom
cbasitodx:sebas.conde/feat/add_vitest_support

Conversation

@cbasitodx

@cbasitodx cbasitodx commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What

Add basic Vitest support to ddtest, including suite-level planning and execution, Vitest-specific dd-trace initialization, native file discovery for Vitest 2 and newer, and config-aware discovery for Vitest 1.6 with a filesystem glob as the final fallback.

Why

ddtest supports JavaScript projects using Jest but cannot currently plan or run Vitest suites. Vitest 1.6 also lacks the list --filesOnly command available in later versions, so it needs a compatibility path that still respects project configuration.

E2E testing

Focused validation completed:

  • go test ./internal/framework ./internal/platform

Manual E2E scenario:

  1. Configure a JavaScript project with dd-trace-js 5.111 or newer and Vitest 1.6, including custom include/exclude rules or projects.
  2. Run ddtest plan --platform javascript --framework vitest and confirm only the files selected by Vitest are planned.
  3. Run ddtest run --platform javascript --framework vitest and confirm the selected files execute with Test Optimization instrumentation.
  4. Repeat with Vitest 2 or newer to validate native list --filesOnly discovery.

@cbasitodx
cbasitodx requested a review from a team as a code owner July 22, 2026 10:51
@cbasitodx
cbasitodx force-pushed the sebas.conde/feat/add_vitest_support branch from 132cedc to 54cbe83 Compare July 22, 2026 11:03
@DataDog DataDog deleted a comment from chatgpt-codex-connector Bot Jul 22, 2026
@cbasitodx

Copy link
Copy Markdown
Contributor 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: 54cbe8316d

ℹ️ 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 internal/framework/vitest.go Outdated
@cbasitodx

Copy link
Copy Markdown
Contributor 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: 49224b2d4e

ℹ️ 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 internal/framework/vitest.go Outdated
@cbasitodx

Copy link
Copy Markdown
Contributor 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: 8f2ab5d99b

ℹ️ 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 internal/framework/vitest.go Outdated
Comment thread internal/framework/vitest.go Outdated
@cbasitodx

Copy link
Copy Markdown
Contributor 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: 2b5ed5dc3c

ℹ️ 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 internal/framework/vitest.go

@anmarchenko anmarchenko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved with one non-blocking suggestion

We will release the vitest support after we create a test playground and do a round of testing with shepherd QA agent

// Add only missing Datadog preloads and preserve existing NODE_OPTIONS.
currentValue, _ := os.LookupEnv(nodeOptionsEnvVar)
requiredOptions := make([]string, 0, 2)
if settings.GetFramework() == "vitest" && !strings.Contains(currentValue, ddTraceRegisterModule) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Non-blocking suggestion:

Could we keep GetPlatformEnv independent of the selected framework and add the Vitest-specific logic to DetectFramework?

DetectFramework already owns the Jest/Vitest selection, while this introduces a hidden global-settings dependency into an otherwise platform-only helper.

Something like:

func (j *JavaScript) DetectFramework() (framework.Framework, error) {
    frameworkName := settings.GetFramework()
    platformEnv := j.GetPlatformEnv()

    var fw framework.Framework
    switch frameworkName {
    case "jest":
        fw = framework.NewJest()
    case "vitest":
        platformEnv = addNodeImport(
            platformEnv,
            ddTraceRegisterModule,
        )
        fw = framework.NewVitest()
    default:
        return nil, ...
    }

    fw.SetPlatformEnv(platformEnv)
    return fw, nil
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ack! I'm merging and I'll open a new PR to highlight this :) good catch

@cbasitodx

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 23, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-23 15:51:00 UTC ℹ️ Start processing command /merge


2026-07-23 15:51:07 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-07-23 16:11:24 UTC ⚠️ MergeQueue: This merge request was unqueued

sebastian.condelorenzo@datadoghq.com unqueued this merge request

@cbasitodx

Copy link
Copy Markdown
Contributor Author

/merge -c

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 23, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-23 16:11:16 UTC ℹ️ Start processing command /merge -c

@cbasitodx

Copy link
Copy Markdown
Contributor Author

Recreated here: #111

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