我正在使用bn-ng-idle
角度模块来检测浏览器中是否有任何不活动。运行单元测试用例时会引发以下错误。我错过了什么吗?
Error: Timeout - Async function did not complete within 5000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)
app.module.ts
@NgModule({
declarations: [AppComponent, AppHeaderComponent, VerticalSidebarComponent, AceComponent],
imports: [BrowserModule, ...],
providers: [BnNgIdleService], // BnNgIdleService service added here
bootstrap: [AppComponent]
})
export class AppModule {}
app.component.ts
export class AppComponent implements OnInit {
constructor(private bnIdle: BnNgIdleService) {}
this.bnIdle.startWatching(3).subscribe(res => {
if (res) {
console.log("session expired");
this.bnIdle.stopTimer();
}
});
}
app.component.spec.ts
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule, ...],
declarations: [AppComponent],
providers: [BnNgIdleService)]
}).compileComponents();
}));