Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if-else path not taken in imports in angular istanbul code coverage report

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?

like image 357
Vishal Anand Avatar asked Jul 10 '18 04:07

Vishal Anand


1 Answers

For Angular 6, it seems that you need to "sourceMap": true to your test like this:

    "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": []
      }
like image 106
JFPicard Avatar answered Oct 10 '22 04:10

JFPicard