Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
spectator.fixture.whenStable() not working in unittest

In our ionic unit test we are migrate our existing unit test to spectator unit test.

What we are doing here is we initialise our unit test with 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();
})

After this we try to run one case.

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()
}))

So actual issue is spectator.fixture.whenStable() is some times worked correctly but generally it not resolved.So what we are writing after that line never executes and provide error like

Error: Timeout - Async function did not complete within 5000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda