Skip to content

Support listing tests related to source files #11016

Description

@joaovitoras

Clear and concise description of the problem

As a developer using Vitest, I want to identify the test files affected by changed source files without executing their test bodies, so that CI can make scheduling decisions before running tests.

vitest related finds and executes affected tests, while vitest list can print matching tests but cannot use the related-module graph. This leaves CI scripts, editor integrations, and sharding workflows to either run tests just to discover them or reimplement dependency analysis.

Suggested solution

Add a --findRelatedTests boolean flag to vitest list, following Jest's naming and argument model. When enabled, positional arguments are source files passed to Vitest's existing related-test resolution. Existing list output modes remain available:

vitest list --findRelatedTests --filesOnly src/index.ts src/utils.ts
vitest list --findRelatedTests --json src/index.ts src/utils.ts

Additional context

A CI pipeline can use --filesOnly to collect affected test files, divide them into balanced groups, and execute each group in a separate shard. This avoids sharding the full test suite for a small source change.

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions