So I have this config:
.nycrc
"extends": "@istanbuljs/nyc-config-typescript","extension": [".ts" ],"exclude": ["**/*.d.ts","**/*.spec.ts" ],"reporter": ["html","lcov","text-summary" ],"lines": 90,"branches": 90,"functions": 90,"statements": 90,"report-dir": "coverage","all": true
.nyc-intrc
{"extends": "./.nycrc","include": ["src/**/*.ts" ]}
package.json
"scripts": {"test:coverage:integration": "nyc --nycrc-path .nyc-intrc --cache false npm run test:integration","test:integration": "mocha -r ts-node/register/transpile-only -r source-map-support/register --recursive 'src/*/__tests__/*.spec.ts' --reporter mochawesome --timeout 1500000" },
So running this using NPM (npm run test:coverage:integration) succeeds. However, the result is not accurate. Some files are reported to have 0% coverage, even though the tests trigger that code and it gets executed.I mean, I added a console.log to one of them. I can see the log in the output when running the tests, but the file still has 0% coverage and Istanbul says even that console.log statement wasn't executed.
Interestingly, this problem does not exist with unit tests. If I run those, the same file gets instrumented and the report is accurate.
I'm using Typescript 4.5.5, Mocha 9.2.0 and Node 14.x
How is this possible? What am I missing here?