Проблема с тестовым набором jasmine, связанная с ошибкой сброса

#angular #jasmine #karma-jasmine

Вопрос:

Я работал над тестовыми примерами(только начал учиться) ,у меня есть компонент с кодом в файле .ts, как показано ниже

 import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { SService } from '../../core/services/s.service';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { CService } from '../../core/services/api/cmd/cmd.service';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { AppConfig } from '../../app.config';
@Component({
  selector: 'app-ind',
  templateUrl: './ind.component.html',
  styleUrls: ['./ind.component.scss']
})
export class IndComponent implements OnInit {
  previewType: string;
  industyVal: any;
  isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
    .pipe(
      map(result => result.matches)
    );

  constructor(
    private router: Router,
    private breakpointObserver: BreakpointObserver,
    private appConfig: AppConfig
  ) {
    this.showLoader = true;
    this.previewType = this.appConfig amp;amp; this.appConfig.config amp;amp; this.appConfig.config.userMode ? this.appConfig.config.userMode : true;
    this.showLoader = false;
  }

  ngOnInit() {
  }

  rexionPage(): void {
    this.router.navigate(['region']);
  }

}
 

тестовые примеры для приведенного выше кода, как показано ниже

 fdescribe('IndComponent', () => {
  let component: IndComponent;
  let fixture: ComponentFixture<IndComponent>;
  let jService: JService;
  let route: Router;

  beforeEach(waitForAsync(() => {
    spyOn(localStorage, 'getItem').and.callFake(LocalStorageStub);

    TestBed.configureTestingModule({
      declarations: [
        IndComponent,
        MComponent,
        CircleComponent,
        FooterComponent,
        ButtonStatePipe,
        LocalizationPipe,
        ContentLocalizationPipe
      ],
      imports: [
        MaterialModule,
        FormsModule,
        HttpClientTestingModule,
        HttpClientModule,
        RouterTestingModule,
        ToastrModule.forRoot(),
        BrowserAnimationsModule
      ],
      providers: [
        { provide: Router, useClass: RouterStub },
        { provide: HttpClient, useClass: FakeHttpClient },
        { provide: AppConfig, useClass: FakeAppConfig },
        DeviceDetectorService,
        TitleCasePipe,
        ButtonStatePipe,
        LocalizationPipe,
        ContentLocalizationPipe
      ],
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(IndComponent);
    component = fixture.componentInstance;
    route = TestBed.get(Router);
    jService = TestBed.get(JService);
    spyOn(jService, 'getJDetails').and.callFake((url: string) => {
      return of({});
    });


  });

  it('should create', fakeAsync(() => {
    fixture.detectChanges(); flush();
    expect(component).toBeTruthy();
  }));

  it('should goToRegion', fakeAsync(() => {
    fixture.detectChanges(); flush();
    const spy = spyOn(route, 'navigate').and.callThrough();
    component.regionPage();
    expect(spy).toHaveBeenCalledTimes(1);
  }));

});
 

but the issue is wheneve I run the above test case it fails with a message as
«flush failed after reaching the limit of 20 tasks. Does your code use a polling timeout?«,i checked this issue is mostly due to timer but there is no timer in this case ,can someone please guide me as to why this error is being thrown.