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

Wrong coverage report #375

Closed
6 tasks done
Nisgrak opened this issue Dec 30, 2021 · 6 comments · Fixed by #655
Closed
6 tasks done

Wrong coverage report #375

Nisgrak opened this issue Dec 30, 2021 · 6 comments · Fixed by #655

Comments

@Nisgrak
Copy link

Nisgrak commented Dec 30, 2021

Describe the bug

The coverage doesn't make sense with the actual code

image
image
image

Reproduction

Github repo: https://github.com/Nisgrak/vitest-coverage-bug

Execute pnpm i && pnpm test:unit

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
    Memory: 1.24 GB / 24.56 GB
    Container: Yes
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.volta/tools/image/node/16.13.1/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 8.1.2 - ~/.volta/tools/image/node/16.13.1/bin/npm
  Browsers:
    Firefox: 95.0.1
  npmPackages:
    vite: ^2.7.2 => 2.7.10 
    vitest: ^0.0.124 => 0.0.124

Used Package Manager

pnpm

Validations

@bompus
Copy link

bompus commented Dec 31, 2021

I'm seeing the same issue. Running via c8 instead of using --coverage displays the correct uncovered line numbers.

Related #371

@sheremet-va sheremet-va added the bug label Jan 1, 2022
@Nisgrak
Copy link
Author

Nisgrak commented Jan 2, 2022

The html report is good with c8 vitest, the text shows the line + 1 (its the 149 but shows the 150), so yes, isn't that bad

Upper vitest --coverage, lower c8 vitest
image
image
image
image
image

@Demivan
Copy link
Member

Demivan commented Jan 23, 2022

@Nisgrak, try it now with Vitest v0.2.0

@Nisgrak
Copy link
Author

Nisgrak commented Jan 23, 2022

Not very accurated. It improved but i think continues wrong.

I update the repo example so can try!

image
image
image

@Demivan
Copy link
Member

Demivan commented Jan 23, 2022

@antfu When vite-node package was moved out, visitedFilesMap updates where removed. So now source-map data it missing - visitedFilesMap is always empty.

@cexbrayat
Copy link
Contributor

I suppose this is the same root cause that @Demivan is mentioning, but Vue files aren't popping up in the report.
See with the provided example running in Stackblitz: https://stackblitz.com/edit/vitest-dev-vitest-ilb2yu?file=vitest.config.ts when you run npm run coverage with the all option:

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   

Adding a new TS file in components with no test does show up in the coverage though, so it looks like it is specific to Vue files

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants