Open JakobJingleheimer opened 2 years ago
yeah I'm struggling to understand how I'm supposed to use --src
and --include
.
Specifying anything for "include" seems to cause the coverage report to be empty, and "src" seems to have no affect whatsoever.
That's exactly the behavior I found as well.
Okay I think I figured it out.
include
and exclude
parameters should be an array of stringsSo I was able to make it work specifying --include
multiple times. Example:
npx c8 --include "src/handlers/*/handler.ts" --include "src/stubs/*.ts" ava
The coverage report correctly shows the files I expected to see.
Hope it helps!
Configuration options for "include" and "src" are very unclear. Without specifying either, several extraneous files are included in the report and some are actually not included at all (despite their tests running).
package.json
```json { "scripts": { "test": "NODE_ENV=test NODE_OPTIONS='--no-warnings --loader=./loader.mjs' mocha './lib'", "test:coverage": "c8 --check-coverage npm test" }, "c8": { "branches": 100, "exclude": [ "**/*.fixture.js", "**/*.spec.{js,cjs,mjs,ts,tsx,jsx}" // c8 is expecting .test.* ] }, } ```file directory
``` ./lib ├ compose.js ├ compose.spec.js ├ diff.js ├ diff.spec.js ├ Form.jsx ├ Form.spec.js ```c8 coverage report
``` // passing mocha spec output for compose.spec.js, diff.spec.js, and Form.spec.js -----------------|---------|----------|---------|---------|------------------ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -----------------|---------|----------|---------|---------|------------------ All files | 92.57 | 95.31 | 66.66 | 92.57 | PACKAGE | 100 | 84.61 | 54.54 | 100 | loader.mjs | 100 | 87.5 | 100 | 100 | 33 mocha.setup.js | 100 | 80 | 28.57 | 100 | 13 PACKAGE/lib | 88.94 | 98.03 | 85.71 | 88.94 |Unexpectedly,
./loader.mjs
and./mocha.setup.js
are included, yetForm.spec.js
is not.Specifying anything for
"include"
seems to cause the coverage report to be empty, and"src"
seems to have no affect whatsoever.