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'); } }@H_403_3@我的代码覆盖率报告显示(E):其他路径未被采用. (I):如果没有采取路径.
在import语句和装饰器的上下文中它意味着什么?
由于这个原因,我的任何测试中的代码覆盖率都未达到100%.
我该如何纠正呢?
我不得不删除:
--sourceMap=false@H_403_3@以前,我已添加此内容以帮助诊断其他问题.所以我在package.json中的测试脚本看起来像这样:
"test": "ng test --code-coverage --sourceMap=false"@H_403_3@我把它改为:
"test": "ng test --code-coverage"@H_403_3@然后,我的所有代码覆盖率都开始正确报告.您可能还想验证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" }