Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include test files in coverage report #493

Open
Xerillio opened this issue Aug 28, 2023 · 0 comments
Open

Include test files in coverage report #493

Xerillio opened this issue Aug 28, 2023 · 0 comments

Comments

@Xerillio
Copy link

  • 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant