Skip to content

Vitest plugin: run only affected tests with DiffCI's graph (tracking issue) #331

Open

Description

@adityankale190895

Goal. A standalone package that lets a Vitest user run only the tests a change affects, using DiffCI's import graph:

npm i -D @diffci.com/vitest   # name to be decided
vitest run --affected          # or a plugin option; see design questions

No account, no DiffCI CLI, no CI step, and nothing sent anywhere. It should feel like part of Vitest, not like a second tool. We want people to find DiffCI through Vitest's own users, the way Supabase grew through Postgres extensions.

What it must do

  • Select from the graph, not the diff. Pick the test files DiffCI's planner selects for the working tree, or for a --base/--head range, including tests reached through imports, fixtures and vi.mock targets.
  • Fall back to the full run, and say why. Do this whenever DiffCI would: config, lockfile or package.json changes, imports it can't follow, an incomplete graph. Never select fewer tests on uncertain evidence. This is the trust promise ("It's just your CI").
  • Explain each pick. Print why each test was selected, and the fallback reason when there is one, in a form a person and an agent can both read.
  • Leave Vitest alone otherwise. Workspaces/projects, reporters, coverage and watch mode keep working. Without the option, Vitest behaves exactly as before.

Design questions to settle first, in docs/design/vitest-plugin.md

  1. Integration point. A Vite/Vitest plugin (for example Vitest's plugin API, configureVitest; check the current docs and the minimum Vitest version it needs), a custom CLI flag, or a thin wrapper command. What do Vitest's own --changed and vitest related already provide, and how does this differ? See #101.
  2. What it depends on. Import Core's planner directly (@diffci.com/core, MIT) rather than the whole CLI. Which modules does it need, and is anything missing from Core's public exports?
  3. Package layout and release. A new package under packages/, with its own entry in release-files.json, npm trusted publishing like the CLI, and a version policy.
  4. Multi-project setups. Vitest workspaces and projects, and monorepos where Vitest runs per package.
  5. Testing. Synthetic Vitest repositories in tests, plus one real public repository named in the design note.

Done when: first, a PR with the design note answering the questions above, reviewed here before any code. Then a first slice that only filters test files and prints the reasons and any fallback, with tests. Watch mode and coverage can come later.

Good background: docs/design/affected-checks.md, docs/change-plan.md, and how the CLI builds a plan in packages/diffci-cli/src/client/. Comment here if you want to take the design note or part of it, and ask anything. Setup and DCO sign-off are in CONTRIBUTING.md.

Activity

  1. added
    enhancement
    help wanted
    javascript
    on Nov 18, 2026
  2. added
    area: vitest
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: vitestenhancementhelp wantedjavascript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions