question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(Ts)-Jest should ignore d.ts files in coverage tests

See original GitHub issue

Issue

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

ts-jest-d-ts-bug

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
kulshekharcommented, Nov 26, 2017

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.

0reactions
GeeWeecommented, Dec 15, 2017

Closing this in favour of #378

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found