jest: [BUG] Typescript bad coverage
Do you want to request a feature or report a bug? BUG
What is the current behavior? Right now when I execute the jest command and it never give me 100% of coverage.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install
and npm test
.
I created an simple example with the bug: Repository
Is just npm install
and after that npm test
and if you guys see the coverage report it appears 87.5% and if you guys open the coverage report in the browser you guys see the issue that I’m having.
What is the expected behavior? That the coverage it will be at 100%
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 17 (7 by maintainers)
ts-jest
README says to add"mapCoverage": true
to jest config. This has fixed the mapping for me.TypeScript support in Jest is not “officially” supported by us. I recommend using
ts-jest
like @kwonoj mentioned. As somebody pointed out above, if the preprocessor prints code with different line numbers etc., Jest cannot do the proper remapping on its own so this is strictly out of the scope of Jest.@kwonoj feel free to send PRs to solve any of the problems you outlined above if that will help you have better coverage support.
Anyone interested in this topic can refer https://github.com/kulshekhar/ts-jest/pull/25 as well, I’ve managed code coverage remapping works with
testresultsprocessor
. Unfortunately this is not ideal approach as given interface from jest lacks of few things.