Branches on constructor not covered

我是研究僧i 提交于 2019-12-03 12:25:31

I've had the same issue for months from the moment I upgraded my projects to angular 4. Unfortunately it is a bug with the angular-cli version 1 and angular 4.

This bug is already logged in the angular-cli project: Test-coverage says that coverage is not 100%, but it truly is! #5871. Unfortunately at the moment, this issue is still open.

This is a snapshot from that logged issue, which matches the one you are asking about:

If you are facing this problem and , nevertheless, want to reach 100% branch coverage, there is at least a workaround available (see https://github.com/angular/angular-cli/issues/5526#issuecomment-324429322).

Simply add /* istanbul ignore next */ after the class export (without any line breaks):

export class InternalComponent {
    constructor(private authService: any) { 
    }
} /* istanbul ignore next */

For Angular 2+ projects, this is now fixed if you upgrade to Angular CLI 1.5.

GitHub post: https://github.com/angular/angular-cli/issues/5526

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!