Skip to content

Run all tests, but report partial coverage, for CI purposes #8747

Description

@kneczaj

Clear and concise description of the problem

This is quite common need at CI pipeline that these two objectives need to be fulfilled:

  1. run all tests
  2. compute coverage of a pull request

The problem is that the second command reruns the same tests. When we talk about CI pipeline which does these two jobs, this is a lot of wasted time.

Suggested solution

My request is to add functionality to limit only collecting the coverage to what --changed (or similar) flag says, and still run the full test set. This could be e.g. --changed-coverage param.

Alternative

First

Currently this can be achieved by two separate commands, but takes up to twice as much time depending on changes:

  1. run all tests: vitest run
  2. compute coverage of a pull request: vitest run --coverage --changed=origin/main

Second

Compute coverage of all the project. Unfortunately this blurs the result as it includes a lot of files which are unrelated to pull request. This also is a problem at legacy projects which are in the process of increasing test coverage as unrelated files which may have no coverage are mixed with affected files with missing coverage.

Additional context

This is performance improvement for CI pipelines which use vitest

Validations

Activity

  1. added theissue type on Oct 20, 2025
  2. AriPerkkio commented on Oct 20, 2025

    @AriPerkkio
    Member

    Could this be achieved already using vitest run --coverage --coverage.include=<here list of files changed in the pull request>. You could use something like https://github.com/marketplace/actions/changed-files or parse the git diff output manually.

  3. kneczaj commented on Oct 20, 2025

    @kneczaj
    Author

    Could this be achieved already using vitest run --coverage --coverage.include=<here list of files changed in the pull request>. You could use something like https://github.com/marketplace/actions/changed-files or parse the git diff output manually.

    It cannot, as what I see, when --coverage --changed is used, it includes also all the files imported by changed files. This is what I look for to check coverage not only on all changed files, but on all affected files. The workaround here would include code parsing and imports analysis what is too much to consider this as a legit workaround.

  4. AriPerkkio commented on Oct 20, 2025

    @AriPerkkio
    Member

    I think this feature makes sense. So to run all tests but get coverage only based on changed files.

    This could be test.coverage.changed, which gets its default value from test.changed.

  5. locked and limited conversation to collaborators on Mar 4, 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

    feat: coverageIssues and PRs related to the coverage featurep2-nice-to-haveNot breaking anything but nice to have (priority)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions