I am using Jasmin, Karma and Angular TestBed for Unit tests in Angular. I am getting an error
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
I am using fakeAsync and tick methods. After searching, i have added timeout parameter for my tests and even given 2000 milliseconds for tick as well.
it('Should setup the initial data', fakeAsync(() => {
fixture.detectChanges();
tick(2000);
expect(getUsersSpy).toHaveBeenCalledTimes(1);
}), 10000);
it('Should ensure form is dirty when user changed', fakeAsync(() => {
fixture.detectChanges();
tick(2000);
fixture.whenStable().then(() => {
userComponentInstance.ngOnInit();
userComponentInstance.onUserChanged();
fixture.detectChanges();
expect(userComponentInstance.userForm.form.dirty).toBeTruthy();
});
}), 10000);
No Luck with the above code. As per jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL I have tried with but it is not working for me. I didnt choose first solution as I am working with fakeAsync and not done
var originalTimeout;
beforeEach(function() {
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
});
afterEach(function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});
I have the below line in one of its child component. The child component created in a loop
ngAfterViewInit() {
setTimeout(() => {
jQuery("#" + this.name).selectpicker();
},0);
}