istanbuljs / nyc

the Istanbul command line interface
https://istanbul.js.org/
ISC License
5.6k stars 359 forks source link

Some TypeScript files missing in coverage #1351

Open janek37 opened 4 years ago

janek37 commented 4 years ago

Link to bug demonstration repository

https://github.com/janek37/nyc-testcase

Expected Behavior

Not ignore files that are not touched by tests.

Observed Behavior

Some files not touched by tests are ignored.

Troubleshooting steps

In the demo repo:

  1. npm install
  2. npm run coverage

Effect: src/foo.ts is ignored in coverage.

  1. Change nyc version in package.json to 14.1.1
  2. Repeat steps 1 and 2

Effect: src/foo.ts is not ignored anymore.

Environment Information

# paste the output here
  System:
    OS: Linux 4.15 Ubuntu 18.04.5 LTS (Bionic Beaver)
    CPU: (2) x64 Intel(R) Pentium(R) CPU G2030 @ 3.00GHz
    Memory: 311.27 MB / 7.66 GB
  Binaries:
    Node: 13.5.0 - ~/.nvm/versions/node/v13.5.0/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v13.5.0/bin/npm
j-szejko commented 3 years ago

No reaction for 3 months :(

fedellen commented 3 years ago

Can confirm this bug. nyc code coverage report was missing most of our TypeScript files. This was on the latest nyc release, ^15.1.0 and using the recommended TS setup.

As mentioned above, setting the version to 14.1.1 has resolved this for now.

kachkaev commented 2 years ago

I've noticed this too in a Next.js project. The fix was to install @istanbuljs/nyc-config-typescript" and then add "extends": "@istanbuljs/nyc-config-typescript", to .nycrc.json.