c8 icon indicating copy to clipboard operation
c8 copied to clipboard

Include test files in coverage report

Open Xerillio opened this issue 2 years ago • 0 comments

  • Version: node v18.7.0 + c8 v8.0.1
  • Platform: 64-bit (Windows)

I'm trying to produce a test coverage report that includes all my source and test TypeScript files. However, I can only seem to get coverage results for the source files.

.c8rc.json:

{
    "all": true,
    "src": ["./src", "./tests"],
    "extension": [".ts"],
    "report-dir": "./coverage"
}

package.json (simplified - see full version with slightly older c8 version here):

    "scripts": {
        "test": "mocha -r ts-node/register -r mocha-suppress-logs './tests/**/*.test.ts'",
        "coverage": "c8 npm test"
    },

From command line I get the following output:

$ npm run coverage

> [email protected] coverage
> c8 npm test


> [email protected] test
> mocha -r ts-node/register -r mocha-suppress-logs './tests/**/*.test.ts'


# Mocha test results stripped away for brevity

-------------------------|---------|----------|---------|---------|-------------------
File                     | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------------|---------|----------|---------|---------|-------------------
All files                |   69.67 |    84.93 |   89.65 |   69.67 |
 src                     |    72.8 |    88.63 |    91.3 |    72.8 |
  azure-helpers.ts       |       0 |        0 |       0 |       0 | 1-14
  commentator.ts         |   96.55 |       75 |     100 |   96.55 | 55-56
  index.ts               |       0 |        0 |       0 |       0 | 1-49
  inputs.ts              |     100 |      100 |     100 |     100 |
  type-guards.ts         |     100 |      100 |     100 |     100 |
  variables.ts           |     100 |      100 |     100 |     100 |
 src/validators          |    62.5 |    79.31 |   83.33 |    62.5 |
  file-glob-validator.ts |     100 |    82.14 |     100 |     100 | 22-26,40
  validator.ts           |       0 |        0 |       0 |       0 | 1-39
-------------------------|---------|----------|---------|---------|-------------------

All tests run successfully, so I was expecting to also see coverage statistics for the ./tests folder. Is this an error in my configuration or an unsupported scenario?

Xerillio avatar Aug 28 '23 12:08 Xerillio