This repository was archived by the owner on Apr 12, 2024. It is now read-only.
mocks.$httpBackend uses mocks.$timeout to control asyncronous requests, which causes $timeout.verifyNoPendingTasks to fail unless an extra $timeout.flush(0) is called #7492
Labels
Milestone
Hey-
I'm trying to add in retry logic to an angular module that makes $http requests. My approach uses $timeout to allow for a delay between attempts. When writing unit tests for this module, I find that an extra $timeout.flush(0) is required to make $timeout.verifyNoPendingTasks() succeed.
Digging into ngMock, it looks like this is due to $httpbackend using $timeout to wrap responses and make then asyncronous.
https://github.com/angular/angular.js/blob/master/src/ngMock/angular-mocks.js#L1117
I have a gist that shows the failure and success once you include $timeout.flush(0)
https://gist.github.com/deignacio/c50787980fbee4c3d1db
Is there any way to decouple the two services to not require this extra flush?
The text was updated successfully, but these errors were encountered: