Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda