Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
espectador.fixture.whenStable() no funciona en unittest

En nuestra prueba de unidad iónica, estamos migrando nuestra prueba de unidad existente a la prueba de unidad de espectador.

Lo que estamos haciendo aquí es inicializar nuestra prueba unitaria con beforeEach.

 beforeEach(async() => { spectator = createComponent() generalConfigService = TestBed.inject(GeneralConfigService) spyOn(spectator.component.generalService, 'getGeneralConfigState').and.returnValue(of(configDataMock)) spectator.component.chartElement = chartViewInputMock.chartElement spectator.component.chartElementID = "0123456789" spectator.component.localstorageservice.setStoragedata('WXcurrentLevelInfo', { "level": "plant", "id": "64291", "timezone": { "abbr": "UTC", "offset": 0, "name": "UTC" } }) spectator.component.localstorageservice.setStoragedata('PlantID', "64291") spectator.component.localstorageservice.setStoragedata('appConfigData', loginSuccessMock.appConfigData) await spectator.component.ngOnInit(); })

Después de esto tratamos de ejecutar un caso.

 it('user can able to duplicate element if dashboard limit not excced',(async(done) => { let spy = spyOn(spectator.component.commonService,'alertMessage') popoverSpy.onDidDismiss.and.returnValue(Promise.resolve({data:'chartDuplicate'})); spectator.component.chartPopover('') // once execution of this function done than only I have to called next lines await spectator.fixture.whenStable() /// Never resolve so got error of timeout in unittest expect(popoverSpy.present).toHaveBeenCalled(); expect(alertSpy.present).toHaveBeenCalled() done() }))

Entonces, el problema real es espectador.fixture.whenStable() algunas veces funcionó correctamente, pero generalmente no se resolvió. Entonces, lo que estamos escribiendo después de esa línea nunca se ejecuta y proporciona un error como

Error: Tiempo de espera: la función asíncrona no se completó en 5000 ms (establecido por jasmine.DEFAULT_TIMEOUT_INTERVAL)

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!