web icon indicating copy to clipboard operation
web copied to clipboard

[test runner] code coverage does not include untested files

Open jmcgavin opened this issue 3 years ago • 6 comments

The includes property of the coverageConfig object does not include untested files in the code coverage. Only files visited during tests are included in the coverage.

I think having the option to include the entire codebase in the code coverage output is a good idea. Either through the includes property or the addition of an all property like the --all flag that can be used with istanbul/nyc or c8.

jmcgavin avatar Feb 20 '22 19:02 jmcgavin

Relates to #1873

jmcgavin avatar Feb 21 '22 16:02 jmcgavin

@LarsDenBakker would love to have your feedback on this. 😃

u-b-i-p-i-x-e-l-s avatar Mar 16 '22 21:03 u-b-i-p-i-x-e-l-s

I'm not sure the "all" flag would change anything here. Did anyone test this? I think we need to see all the files in the browser to make them show up in the coverage.

LarsDenBakker avatar Mar 16 '22 22:03 LarsDenBakker

This may be overkill but here's a workaround:

  1. before running web-test-runner, run a new script that finds all your files
  2. using that script, generate a new TS/JS file that imports all the found file paths from step 1
  3. include that new file in the test files that web-test-runner executes
  4. now all your files are included in the coverage report because the browser imported them all!

electrovir avatar Dec 12 '22 12:12 electrovir

This may be overkill but here's a workaround:

  1. before running web-test-runner, run a new script that finds all your files

  2. using that script, generate a new TS/JS file that imports all the found file paths from step 1

  3. include that new file in the test files that web-test-runner executes

  4. now all your files are included in the coverage report because the browser imported them all!

Another approach instead of creating a new test file is to add it to Istanbul reporter as 0 coverage for all files found then merge the coverage data found.

mohamedmansour avatar May 01 '24 16:05 mohamedmansour