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. screen shot 2016-10-10 at 5 58 40 pm

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)

Most upvoted comments

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.

  • jest does not allow return post processed results to back to jest runtime
  • testresults delivered by testresultsprocessor does not contain empty coverage from uncovered files
  • jest configuration is not passed into processor, so process need to own responsibility if it need to figure out current configuration of jest