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');
}
}
My code coverage report shows (E): else path not taken. (I): if path not taken. What does it mean in the context of import statements and decorators? My code coverage is not reaching to 100% in any of my tests due to this. How do I rectify it?
I had to remove:
--sourceMap=false
Previously, I had added this to help diagnose other issues. So my test script in package.json looked like this:
"test": "ng test --code-coverage --sourceMap=false"
I changed it to be:
"test": "ng test --code-coverage"
Then, all of my code coverage started reporting correctly. You may also want to verify your devDependencies in package.json. I am using Angular 6 so they look like this:
"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"
}