(Ts)-Jest should ignore d.ts files in coverage tests
See original GitHub issueIssue
In --coverage mode, ts-jest attempts to cover module type declaration files (*.d.ts) which results in an error (see bellow). Seems related to #136
error stack
Failed to collect coverage from <rootDir>/src/dummy.d.ts
ERROR: Error: Debug Failure. False expression: Output generation failed
STACK: Error: Debug Failure. False expression: Output generation failed
at Object.transpileModule (<rootDir>/node_modules/typescript/lib/typescript.js:86543:18)
at Object.process (<rootDir>/node_modules/ts-jest/dist/preprocessor.js:22:32)
at ScriptTransformer.transformSource (<rootDir>/node_modules/jest-runtime/build/script_transformer.js:218:35)
at exports.default (<rootDir>/node_modules/jest/node_modules/jest-cli/build/generate_empty_coverage.js:32:5)
at module.exports (<rootDir>/node_modules/jest/node_modules/jest-cli/build/reporters/coverage_worker.js:52:94)
at handle (<rootDir>/node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (<rootDir>/node_modules/worker-farm/lib/child/index.js:51:3)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emit (internal/child_process.js:772:12)
Expected behavior
ts-jest should ignore module type declaration files (*.d.ts) in coverage tests. Those files are only relevant for type checking and are not transpiled to executable code. Thus they are irrelevant for code coverage.
MWE
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
How can I ignore a file pattern for Jest code coverage?
I've tried regex and file patterns but none of these just ignores the *.entity.ts files in the final report. When I add for...
Read more >Configuring Code Coverage for TypeScript Files in Jest
Open up your package.JSON file and in the Jest config, add a new key called collect coverage from. This is going to be...
Read more >Jest ignore or exclude file/function/statement from test coverage
Exclude /ignore file(s) from coverage by not including it in the coverage collection configuration ... Important: make sure to wrap the ignored ......
Read more >Configuring Jest
Indicates whether the coverage information should be collected while executing the test. Because this retrofits all executed files with coverage ...
Read more >Measuring Typescript Code Coverage with Jest and GitHub ...
Running Typescript Tests and Coverage Locally with Jest ... type-checking */ "skipLibCheck": true /* Skip type checking all .d.ts files.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

ts-jest doesn’t handle anything related to coverage at all. That’s handled by Jest. Moreover, given that jest has the
coveragePathIgnorePatterns(as you pointed out) which allows ignoring these files, I’m not sure that hard-coding this behavior would be a very good idea.Closing this in favour of #378