Ts-jest: How to display remapped coverage report in the terminal?

Created on 25 Jan 2017  路  7Comments  路  Source: kulshekhar/ts-jest

I apologize if I'm missing something obvious or if I'm repeating this issue.

Current Behavior

The remapped coverage works in the browser:

screen shot 2017-01-24 at 3 58 48 pm
screen shot 2017-01-24 at 3 55 43 pm

The terminal is displaying the unmapped coverage, look at "branch" and "uncovered lines":

screen shot 2017-01-19 at 3 12 28 pm

jest config in package.json

screen shot 2017-01-25 at 12 07 58 pm

Desired Behavior

Remapped coverage displays in the terminal.

What am I missing?
Thanks in advance.

Most helpful comment

I've been trying to wrap my head around the current status of this, and I thought it'd be a good idea to jot down my current conclusions (both to inform others, and to double-check any incorrect assumptions I've made).

So, as far as I can tell, it is currently impossible for ts-jest to tell Jest what the correct coverage is (although it _can_ output the correct coverage to the developer, [currently])(https://github.com/kulshekhar/ts-jest/issues/61) in the remapped directory inside the coverage directory configured for Jest).

However, a PR has been accepted into Jest that should make this possible in the future. If the developer enables the mapCoverage option, then from Jest 20 onwards (we're at version 19 at the time of writing), ts-jest and other preprocessors should be able to report the actual coverage back to Jest. Or at least, the actual coverage as far as the source maps are accurate, which should be fine most of the time.

So for now, we'll have to wait for Jest 20, after which ts-jest can be extended to report the coverage back to Jest.

As a workaround until that time, I've created a small CLI-tool that you can point at your remapped coverage report to pass or fail a CI build depending on whether thresholds are met.

All 7 comments

Thanks for the quick response. Sorry for the repeat question.

I've been trying to wrap my head around the current status of this, and I thought it'd be a good idea to jot down my current conclusions (both to inform others, and to double-check any incorrect assumptions I've made).

So, as far as I can tell, it is currently impossible for ts-jest to tell Jest what the correct coverage is (although it _can_ output the correct coverage to the developer, [currently])(https://github.com/kulshekhar/ts-jest/issues/61) in the remapped directory inside the coverage directory configured for Jest).

However, a PR has been accepted into Jest that should make this possible in the future. If the developer enables the mapCoverage option, then from Jest 20 onwards (we're at version 19 at the time of writing), ts-jest and other preprocessors should be able to report the actual coverage back to Jest. Or at least, the actual coverage as far as the source maps are accurate, which should be fine most of the time.

So for now, we'll have to wait for Jest 20, after which ts-jest can be extended to report the coverage back to Jest.

As a workaround until that time, I've created a small CLI-tool that you can point at your remapped coverage report to pass or fail a CI build depending on whether thresholds are met.

Thanks for the update and work around, much appreciated.

Coverage is no longer handled by ts-jest (see #200)

If this issue isn't addressed AND if you think the fix needs to be in ts-jest, feel free to either open a new issue or leave a comment here to reopen this.

Thanks for the update on this issue @kulshekhar

Unfortunately it does not work at the moment: https://github.com/kulshekhar/ts-jest/issues/211

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artola picture artola  路  3Comments

TKJohn picture TKJohn  路  4Comments

stangerjm picture stangerjm  路  4Comments

ozum picture ozum  路  4Comments

masters3d picture masters3d  路  4Comments