Why is nyc coverage with typescript (using mocha) returning zero coverage

121 Views Asked by At

I was going through some similar questions, tried various .nycrc config options, none of them worked.

Here's a repro: https://codesandbox.io/p/sandbox/xenodochial-babbage-jrwj0b

If you run npm run coverage, you will get:

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================

Even though the only line to cover is covered (using ts-mocha for testing.)

The configurations I tried to mix, according to other posts, in and didn't work:

"exclude-after-remap": false,
"exclude": [
    "*.test.*",
    "**/*.d.ts"
],
"extension": [
    ".js",
    ".jsx",
    ".ts",
    ".tsx"
],
"check-coverage": true,
"cache": false,
"all": false,
"source-map": true,
"produce-source-map": true,
0

There are 0 best solutions below