import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { DashboardComponent } from './dashboard.component'; import { DashboardModule } from './dashboard.module'; import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('DashboardComponent', () => { let component: DashboardComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ DashboardModule, RouterTestingModule, BrowserAnimationsModule, HttpClientTestingModule ] }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(DashboardComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); it('should test the closeAlert method', () =>{ component.alerts=[1,2,3,4,5]; component.closeAlert(2); expect(component.alerts).toEqual([1,3,4,5]); }) });