Vitest/C8 coverage includes the unit test files themselves
See original GitHub issueDescribe the bug
As per the docs I have the following npm script to generate the coverage report:
"coverage": "vitest run --coverage"
However it includes the unit test files themselves which is not useful and also leads to incorrect coverage metrics. Please can this be addressed in Vite?
Reproduction
Follow getting started guide and make a basic function and a unit test that imports that function. Have "coverage": "vitest run --coverage"
in npm scrips and run it. Observe the reports in both the console and HTML istanbul report contain both SUT’s and the unit tests themselves.
System Info
Windows and Linux, Node 16.
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.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Coverage | Guide - Vitest
Vitest supports Native code coverage via c8 and instrumented code ... To configure it, set test.coverage options in your config file:.
Read more >Should coverage.py present unit test code's coverage too?
The coverage report from coverage.py includes some coverage for actual unit tests code along "production" code and I think I'm doing ...
Read more >Code coverage testing - Visual Studio (Windows)
To determine what proportion of your project's code is being tested by coded tests such as unit tests, you can use the code...
Read more >Test coverage visualization - GitLab Docs
When submitting many files, it can take a few minutes for coverage to show on a merge request. The visualization only displays after...
Read more >What is Unit Testing & Code Coverage and How to Use Them ...
So how exactly does Python know which unit tests are passing? The compiler will run each method in the unit test file. If...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It should already be excluded. We have
defaults.ts
file with default coverage. We need to addspec
alongsidetest
there. PR welcome.Which begs the question, what happens if you do in-source testing? I love that feature, and I can’t leave it.