You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run all tests, but report partial coverage, for CI purposes #8747
This is quite common need at CI pipeline that these two objectives need to be fulfilled:
run all tests
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:
run all tests: vitest run
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
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.
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.
Activity
AriPerkkio commentedon Oct 20, 2025
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 thegit diffoutput manually.kneczaj commentedon Oct 20, 2025
It cannot, as what I see, when
--coverage --changedis 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.AriPerkkio commentedon Oct 20, 2025
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 fromtest.changed.docs: document coverage.changed option (vitest-dev#8747)
docs: document coverage.changed option (vitest-dev#8747)