web
web copied to clipboard
[test runner] code coverage does not include untested files
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.
The @web/test-runner-coverage-v8 package uses the v8-to-istanbul lib which initializes all
to false.
Relates to #1873
@LarsDenBakker would love to have your feedback on this. 😃
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.
This may be overkill but here's a workaround:
- before running web-test-runner, run a new script that finds all your files
- using that script, generate a new TS/JS file that imports all the found file paths from step 1
- include that new file in the test files that web-test-runner executes
- now all your files are included in the coverage report because the browser imported them all!
This may be overkill but here's a workaround:
before running web-test-runner, run a new script that finds all your files
using that script, generate a new TS/JS file that imports all the found file paths from step 1
include that new file in the test files that web-test-runner executes
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.