Skip to content

0% coverage for files only containing TypeScript interfaces #494

@Xerillio

Description

@Xerillio
  • 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)?

// .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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions