Jest-preset-angular: The coverage for constructors with injectables is wrong

Created on 4 Oct 2018  路  10Comments  路  Source: thymikee/jest-preset-angular

jest 23.6.0
ts-jest 23.10.3
jest-preset-angular-6.0.1

screen shot 2018-10-03 at 7 12 46 pm

Most helpful comment

confirm fixed in 7.0.0-alpha.1 cc @huafu

All 10 comments

ts-jest supports ignoreCoverageForAllDecorators
and some rules in preprocessor, I wonder if it's possible to use ts-jest for ts files and this preset for html?

This is a known issue and at the moment we still can't figure out how to solve this.

Basically this preset uses ts-jest to be able to run Jest with Angular ts file and add extra 2 snapshot serializers to support rendering HTML template.

Besides, the current version 6.0.1 isn't compatible with ts-jest 23.10.0 therefore we don't know if the coverage issue has been solved yet or not.

PR is welcome to solve coverage issue. We plan to make this preset compatible with 23.10.0 which is mentioned in #195

Hey @thymikee,

wrote a plugin based on yours some time ago, which fixes the coverage problem. Please see https://github.com/100hz/jest-preset-ngx/blob/master/preprocessor.js#L33 It is mainly based on your work with some patches for accurate coverage. If you like i can make a PR, or you simply take this piece of code yourself.

Thanks for your work!

@100hz I'm curious why we actually need that. If that works though, I'm happy to accept a PR with your changes, provided that you add some tests for this js regex.

according to @huafu, ts-jest 23.10.x can solve this issue but have to wait for #201 to be able test this issue. I think perhaps @100hz solution can be a temporary one. If #201 finishes and it solves this issue, we can remove @100hz solution. If it doesn't solve, we can make @100hz solution as official.

What do you think ? @100hz @thymikee

Maybe we should just fix the new ts-jest integration. Is anybody willing to take over that PR?

I'm sorry, new location, new house, new job, ... if it's not done yet as soon as I have a bit of time, I'll continue my work, but I don't think I'll be able to work on it before a 1 or 2 weeks

Awesome, thanks! Enjoy new house :)

confirm fixed in 7.0.0-alpha.1 cc @huafu

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jesusbotella picture jesusbotella  路  8Comments

brandonroberts picture brandonroberts  路  3Comments

maxencefrenette picture maxencefrenette  路  8Comments

ilancohen picture ilancohen  路  7Comments

markgoho picture markgoho  路  7Comments