Resolving the "n timer(s) still in the queue" Error In Angular Unit Tests
A few months ago one of the developers I work with ran into the below error in an Angular unit test: 1 timer(s) still in the queue The fix was to specify a particular amount of time in the tick() call as shown below: it( 'should set accountConfirmationDetails when getAccountConfirmationDetails is called' , fakeAsync(() => { // Arrange let spyGetAccountConfirmationDetails = spyOn(accountService, 'getAccountConfirmationDetails' ) .and .returnValue(Promise.resolve(AccountMockData.mockAccountConfirmationDetails)); // Act fixture.detectChanges(); tick(15000); // Assert expect(spyGetPaymentConfirmationDetails).toHaveBeenCalled(); expect(comp.zone).toBe(42); expect(comp.hasValidProfile).toBeTruthy(); })); Hoping this helps someone!
Comments
Post a Comment