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): else path not taken。 (I):如果没有选择路径。 在 import 语句和装饰器的上下文中是什么意思? 因此,在我的任何测试中,我的代码覆盖率都没有达到 100%。 我该如何纠正?
最佳答案
对于 Angular 6,您似乎需要像这样 "sourceMap": true
到您的 test
:
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "test/test.ts",
"karmaConfig": "./karma.conf.js",
"sourceMap": true,
"polyfills": "src/polyfills.ts",
"tsConfig": "test/tsconfig.spec.json",
"scripts": [],
"styles": [],
"assets": [
"src/assets"
],
"codeCoverageExclude": []
}
关于angular - Angular Istanbul 尔代码覆盖率报告中的导入未采用 if-else 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51257459/