How to collect test coverage including untested files? #55447
Replies: 3 comments
-
Also interested ! I think this is related to nodejs/help#4487 |
Beta Was this translation helpful? Give feedback.
-
Coverage is collected using v8's takeCoverage method, which means it is only aware of code that has actually run. |
Beta Was this translation helpful? Give feedback.
-
Yes, it is possible to include untested files in your coverage report, but it often requires additional configuration because many coverage tools only include files that were executed or imported during the test run by default. To include all files, even those that were not imported or executed during the test run, you need to configure your testing or coverage tool explicitly. Here's how to do it using some common tools and frameworks: For Node.js with
|
Beta Was this translation helpful? Give feedback.
-
Is it possible to include untested files in coverage report?
Reason: I want to know how much code I have uncovered in my project overall. I want to see files for which I haven't created any tests and never imported them anywhere.
Example:
Let's say I have
src/index.js
file. And I runnode --test --experimental-test-coverage --test-coverage-include="src/**/*"
in the root of my project. My expectation: report should includeindex.js
showing that zero lines covered with tests.Beta Was this translation helpful? Give feedback.
All reactions