After upgrading a project to Angular 6, some previously successful tests are now failing. Below is an example of one such test:
beforeEach(
async(() => {
TestBed.configureTestingModule({
declarations: [CampaignsDetailScheduleComponent],
imports: [
SomeModule,
ReactiveFormsModule,
TranslateModule.forRoot({
loader: { provide: TranslateLoader, useClass: TranslateFakeLoader }
}),
StoreModule.forRoot({})
],
providers: [{ provide: ConfigService, useValue: ConfigServiceMock }],
schemas: [NO_ERRORS_SCHEMA]
});
fixture = TestBed.createComponent(CampaignsDetailScheduleComponent);
comp = fixture.componentInstance; // Component test instance
_store = fixture.debugElement.injector.get<Store<State>>(Store);
comp.campaignModel$ = of(CampaignMockData);
fixture.detectChanges();
})
);
it(
'close edit schedule modal',
async(() => {
spyOn(_store, 'dispatch');
comp.onClose();
const args = new ShowHideEditScheduleModal(false);
expect(_store.dispatch).toHaveBeenCalledWith(args);
})
);
This specific test passed without issues before the Angular 6 update. However, it now produces the following error:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.--Pendng async tasks are: [type: macroTask, source: setInterval, args: {handleId:4072,isPeriodic:true,delay:0,args:[object Arguments],__creationTrace__:[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]},type: macroTask, source: setInterval, args: {handleId:4075,isPeriodic:true,delay:0,args:[object Arguments],__creationTrace__:[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]}]
If anyone has insights on what might be causing this issue, it would be greatly appreciated!