Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage report is not only generated for changed files in watch mode #2316

Closed
6 tasks done
netcoding87 opened this issue Nov 11, 2022 · 2 comments · Fixed by #2385
Closed
6 tasks done

Coverage report is not only generated for changed files in watch mode #2316

netcoding87 opened this issue Nov 11, 2022 · 2 comments · Fixed by #2385
Labels
enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature pr welcome

Comments

@netcoding87
Copy link

Describe the bug

As a developer using Vitest I want to coverage report in watch mode only for files affected by code changes instead of all so that I can easily see how my changes affected the code.

I know this behavior from using jest on projects setup with cra. In my current project with more than 100 files it is very frustrating to have to search out the files from the report after every run...

Reproduction

Repository to investigate: https://github.com/netcoding87/vitest-coverage (see README.md)

System Info

System:
    OS: macOS 12.6.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 246.67 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
  Browsers:
    Chrome: 107.0.5304.110
    Firefox: 106.0.3
    Safari: 16.1
  npmPackages:
    @vitejs/plugin-react: ^2.2.0 => 2.2.0 
    vite: ^3.2.3 => 3.2.3 
    vitest: ^0.25.1 => 0.25.1

Used Package Manager

npm

Validations

@sheremet-va sheremet-va added enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature pr welcome labels Nov 11, 2022
@DevathiMahesh
Copy link

Yes. Even i am facing the same issue. Its running for all the files in the codebase.......

@AriPerkkio
Copy link
Member

@netcoding87, @DevathiMahesh, does cleanOnRerun work for you? In the reproduction case it is providing same experience as Jest does. It doesn't exactly limit the included files to only those ones that have changed, but includes those ones that are used by the test that was re-run. This will limit the coverage report a lot.

import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    coverage: {
      provider: "istanbul",
      cleanOnRerun: true,
    },
    reporters: "verbose",
  },
});

What Jest does is more complicated. It's using git to see which files have changes, and includes only those ones in coverage report.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants