import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RunComponent } from './run.component'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; describe('RunComponent', () => { let component: RunComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ RunComponent ], imports: [HttpClientTestingModule, RouterTestingModule] }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(RunComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); it('should test ngOnInit method', () => { component.reportType = "Dashboard"; component.ngOnInit(); expect(component.stepNo).toEqual("4"); component.reportType = "test"; component.ngOnInit(); expect(component.stepNo).toEqual("8"); }); });