vitest: Coverage report does not include .vue files
Describe the bug
The coverage seems to only cover .vue
files that are currently tested, giving wrong coverage reports since files without tests are not covered.
Possible related issues/PRs
https://github.com/vitest-dev/vitest/issues/559
https://github.com/vitest-dev/vitest/pull/518
Reproduction
https://github.com/kouts/vitest-coverage
running npm run coverage
gives us the following
while it should include the uncovered
src/Hello.vue
component
System Info
System:
OS: macOS 11.6.2
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 192.20 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.2/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
Browsers:
Chrome: 98.0.4758.80
Firefox: 96.0.2
Firefox Developer Edition: 97.0
Safari: 15.2
Safari Technology Preview: 15.4
npmPackages:
@vitejs/plugin-vue: ^2.1.0 => 2.1.0
vitest: latest => 0.2.7
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 21 (7 by maintainers)
Commits related to this issue
- feat(useEventBus): new Function `once` (#680) Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com> — committed to chaii3/vitest by hairyf 3 years ago
https://github.com/bcoe/c8#checking-for-full-source-coverage-using---all
c8
by default only collects coverage for files that have been tested. You can passall: true
option to Vitestcoverage
config to report coverage for all files. You will probably need to adjustcoverage.include
option too, to not receive coverage for files that you don’t want.@kouts is this issue still valid? The reproduction case seems to work as expected:
@mahmost your reproduction case seems to work fine with changes of on-going PR #2591. It’s having the same issue as #2539.
Maybe it’s time to close this issue and open new ones if there are still existing problems.
I’m using vitest@0.12.6 and have c8@7.11.3 installed. It seems now that my coverage does show all of the .vue files that I don’t have tests for in the coverage report, but almost all are showing 100%. Weirdly there are a couple files that are still at zero.
We made some major App changes yesterday so maybe that’s affecting it, since I’m pretty sure yesterday we were seeing the files but they were listed at 0% covered. But… seems weird that today they would go to 100%, unless coverage just isn’t being calculated correctly in .vue files?
I’m kind of lost here, so I’m curious what others are seeing.
C8 already merged the PR that will make this possible.
Hi @AriPerkkio, unfortunately, i am still experiencing this issue and have opened a new issue here. i have tried using both
c8
andistanbul
and they both yield the same result.Peeky had custom code before but it was too much work to implement istanbul and I just switched to c8 for the coverage report.