Designer Branches Not Included

I create my unit tests with Jasmine and I have a question about a covered branch.

Does anyone know why part of the code shows that the branches are not covered, as we can see below?

enter image description here

This is unit test:

describe('MyComponent', () => {
  let component: MyComponent;
  let fixture: ComponentFixture<MyComponent>;
  let myService: MyService;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ MyComponent ],
      imports: [ MaterializeModule, FormsModule, ReactiveFormsModule, HttpModule ],
      providers: [
        MyService,
        FormBuilder
      ]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(MyComponent);
    component = fixture.componentInstance;
    slotsService = TestBed.get(MyService);
    fixture.detectChanges();
  });

  function updateForm(name, surname) {
    component.myForm.controls['name'].setValue(name);
    component.myForm.controls['surname'].setValue(name);
  }

  it('should create', () => {
    expect(component).toBeTruthy();
  });
}
+6
source share
3 answers

I had the same problem for several months from updating my projects to angular 4. Unfortunately, this is a bug with angular-cli version 1 and angular 4.

angular-cli: , 100%, ! # 5871. , .

, , :

+4

, , 100% - , , , (. https://github.com/angular/angular-cli/issues/5526#issuecomment-324429322).

/* istanbul ignore next */ ( ):

export class InternalComponent {
    constructor(private authService: any) { 
    }
} /* istanbul ignore next */
+1

For Angular 2+ projects, this is now fixed if you upgrade to Angular CLI 1.5.

GitHub post: https://github.com/angular/angular-cli/issues/5526

0
source

Source: https://habr.com/ru/post/1016300/


All Articles