Description
Node.js Version
v22.9.0
NPM Version
v10.8.3
Operating System
Linux razz 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
Other
Description
If I have two files, add.js
and subtract.js
along with tests for just one of them add.test.js
which imports add.js
I would like the --experimental-test-coverage
to report that I have only tested 50% of files.
I've tried using --test-coverage-include='*.js'
but this does not seem to include the additional files, I've also tried changing the test pattern node --test *.js
which does seem to sort-of work, but it adds extra processing for every file (~1s per file) and logs it as a test suite file in the console, which is undesirable.
Is there a way to make sure coverage reports across all files with a given pattern?
Minimal Reproduction
https://github.com/swantzter/poc-node-test-coverage
Output
Given the three files above, run node --test --experimental-test-coverage --test-coverage-include='*.js' --test-coverage-exclude='*.test.js'
This prints
[...]
# -------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# -------------------------------------------------------
# add.js | 100.00 | 100.00 | 100.00 |
# -------------------------------------------------------
# all f… | 100.00 | 100.00 | 100.00 |
# -------------------------------------------------------
# end of coverage report
I would expect, or am trying to find a way to make it print
[...]
# ------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# ------------------------------------------------------------
# add.js | 100.00 | 100.00 | 100.00 |
# subtract.js | 0.00 | 0.00 | 0.00 | 1-3
# ------------------------------------------------------------
# all files | 50.00 | 50.00 | 50.00 |
# ------------------------------------------------------------
# end of coverage report
Before You Submit
- I have looked for issues that already exist before submitting this
- My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask