0% coverage for files only containing TypeScript interfaces
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
* **Version**: node v18.7.0 + c8 v8.0.1
* **Platform**: 64-bit (Windows)
I'm running `c8` using `mocha` with `ts-node/register` and I'm wondering if that might cause the issue. Essentially, I have a file `task-result.ts` that only contains a `ITaskResult` interface. This is used from `task-runner.ts` (`import { ITaskResult } from "./task-result"`). I have tests with 100% coverage for `task-runner.ts`, but using the `--all` flag, `c8` reports 0% coverage for `task-result.ts`.
If I move the interface into `task-runner.ts` instead, `task-runner.ts` still reports 100% coverage as expected.
Is this an artefact from TS interfaces not being transpiled to JS and/or related to the same underlying issue in #182? Or is there a way to solve it while keeping the interface in its own file (I'd prefer not having to exclude individual files like this)?
```jsonc
// .c8rc.json
{
"all": true,
"src": ["./src"],
"extension": [".ts"],
"report-dir": "./coverage"
}
// package.json (snippet)
"scripts": {
"test": "mocha -r ts-node/register -r mocha-suppress-logs './tests/**/*.test.ts'",
"coverage": "c8 npm test"
},
```
If necessary, I can create a small example to reproduce it.
Contributor guide
Assessment
This issue has not been assessed yet.