if-else路径未在角度istanbul代码覆盖率报告中导入

前端之家收集整理的这篇文章主要介绍了if-else路径未在角度istanbul代码覆盖率报告中导入前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
import { Component,OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';

@Com(I)ponent({
  selector: 'app-fruit-cake',(E)
  templateUrl: './fruit-cake.component.html',styleUrls: ['./fruit-cake.component.scss'],})
expo(E)rt class FruitCakeComponent {
  constructor(private _title: Title) {
    _title.setTitle('Cake');
  }
}

我的代码覆盖率报告显示(E):其他路径未被采用. (I):如果没有采取路径.
在import语句和装饰器的上下文中它意味着什么?
由于这个原因,我的任何测试中的代码覆盖率都未达到100%.
我该如何纠正呢?

我不得不删除
--sourceMap=false

以前,我已添加内容以帮助诊断其他问题.所以我在package.json中的测试脚本看起来像这样:

"test": "ng test --code-coverage --sourceMap=false"

我把它改为:

"test": "ng test --code-coverage"

然后,我的所有代码覆盖率都开始正确报告.您可能还想验证package.json中的devDependencies.我正在使用Angular 6,所以它们看起来像这样:

"devDependencies": {
    "@angular/compiler-cli": "^6.0.3","@angular-devkit/build-angular": "~0.6.8","typescript": "~2.7.2","@angular/cli": "~6.0.8","@angular/language-service": "^6.0.3","@types/jasmine": "~2.8.6","@types/jasminewd2": "~2.0.3","@types/node": "~8.9.4","codelyzer": "~4.2.1","jasmine-core": "~2.99.1","jasmine-spec-reporter": "~4.2.1","karma": "~1.7.1","karma-chrome-launcher": "~2.2.0","karma-coverage-istanbul-reporter": "~2.0.0","karma-jasmine": "~1.1.1","karma-jasmine-html-reporter": "^0.2.2","protractor": "~5.3.0","ts-node": "~5.0.1","tslint": "~5.9.1"
  }
原文链接:https://www.f2er.com/angularjs/140897.html

猜你在找的Angularjs相关文章