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

218
Views
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
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!