{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/7492","repository_url":"https://api.github.com/repos/angular/angular.js","labels_url":"https://api.github.com/repos/angular/angular.js/issues/7492/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/7492/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/7492/events","html_url":"https://github.com/angular/angular.js/issues/7492","id":33713790,"number":7492,"title":"mocks.$httpBackend uses mocks.$timeout to control asyncronous requests, which causes $timeout.verifyNoPendingTasks to fail unless an extra $timeout.flush(0) is called","user":{"login":"deignacio","id":74839,"avatar_url":"https://avatars.githubusercontent.com/u/74839?v=3","gravatar_id":"","url":"https://api.github.com/users/deignacio","html_url":"https://github.com/deignacio","followers_url":"https://api.github.com/users/deignacio/followers","following_url":"https://api.github.com/users/deignacio/following{/other_user}","gists_url":"https://api.github.com/users/deignacio/gists{/gist_id}","starred_url":"https://api.github.com/users/deignacio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deignacio/subscriptions","organizations_url":"https://api.github.com/users/deignacio/orgs","repos_url":"https://api.github.com/users/deignacio/repos","events_url":"https://api.github.com/users/deignacio/events{/privacy}","received_events_url":"https://api.github.com/users/deignacio/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular.js/labels/component:%20$http","name":"component: $http","color":"d7e102"},{"url":"https://api.github.com/repos/angular/angular.js/labels/component:%20ngMock","name":"component: ngMock","color":"bfd4f2"},{"url":"https://api.github.com/repos/angular/angular.js/labels/frequency:%20moderate","name":"frequency: moderate","color":"fef2c0"},{"url":"https://api.github.com/repos/angular/angular.js/labels/needs:%20investigation","name":"needs: investigation","color":"444444"},{"url":"https://api.github.com/repos/angular/angular.js/labels/severity:%20confusing","name":"severity: confusing","color":"cd19e7"},{"url":"https://api.github.com/repos/angular/angular.js/labels/type:%20bug","name":"type: bug","color":"000000"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/angular/angular.js/milestones/27","html_url":"https://github.com/angular/angular.js/milestones/Backlog","labels_url":"https://api.github.com/repos/angular/angular.js/milestones/27/labels","id":489171,"number":27,"title":"Backlog","description":"Holds the backlog of issues and pull requests that have been triaged.\r\n\r\nBefore assigning items to this milestone they should be labelled, at the very least with the correct \"type\" label (i.e. \"issue\", \"pr\", \"bug\", \"regression\", \"chore\", \"docs\", etc).  Preferably you should also check for duplicate issues/PRs, note CLA status and assign \"complexity\" and \"impact\" labels too.","creator":{"login":"IgorMinar","id":216296,"avatar_url":"https://avatars.githubusercontent.com/u/216296?v=3","gravatar_id":"","url":"https://api.github.com/users/IgorMinar","html_url":"https://github.com/IgorMinar","followers_url":"https://api.github.com/users/IgorMinar/followers","following_url":"https://api.github.com/users/IgorMinar/following{/other_user}","gists_url":"https://api.github.com/users/IgorMinar/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorMinar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorMinar/subscriptions","organizations_url":"https://api.github.com/users/IgorMinar/orgs","repos_url":"https://api.github.com/users/IgorMinar/repos","events_url":"https://api.github.com/users/IgorMinar/events{/privacy}","received_events_url":"https://api.github.com/users/IgorMinar/received_events","type":"User","site_admin":false},"open_issues":602,"closed_issues":1177,"state":"open","created_at":"2013-11-18T23:30:35Z","updated_at":"2016-03-29T08:57:12Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2014-05-16T22:12:30Z","updated_at":"2016-03-29T08:57:12Z","closed_at":"2016-03-29T08:57:12Z","body":"Hey-\r\n\r\nI'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.  \r\n\r\nDigging into ngMock, it looks like this is due to $httpbackend using $timeout to wrap responses and make then asyncronous.\r\nhttps://github.com/angular/angular.js/blob/master/src/ngMock/angular-mocks.js#L1117\r\n\r\nI have a gist that shows the failure and success once you include $timeout.flush(0)\r\n\r\nhttps://gist.github.com/deignacio/c50787980fbee4c3d1db\r\n\r\nIs there any way to decouple the two services to not require this extra flush?"},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/202784722","html_url":"https://github.com/angular/angular.js/issues/7492#issuecomment-202784722","issue_url":"https://api.github.com/repos/angular/angular.js/issues/7492","id":202784722,"user":{"login":"gkalpak","id":8604205,"avatar_url":"https://avatars.githubusercontent.com/u/8604205?v=3","gravatar_id":"","url":"https://api.github.com/users/gkalpak","html_url":"https://github.com/gkalpak","followers_url":"https://api.github.com/users/gkalpak/followers","following_url":"https://api.github.com/users/gkalpak/following{/other_user}","gists_url":"https://api.github.com/users/gkalpak/gists{/gist_id}","starred_url":"https://api.github.com/users/gkalpak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkalpak/subscriptions","organizations_url":"https://api.github.com/users/gkalpak/orgs","repos_url":"https://api.github.com/users/gkalpak/repos","events_url":"https://api.github.com/users/gkalpak/events{/privacy}","received_events_url":"https://api.github.com/users/gkalpak/received_events","type":"User","site_admin":false},"created_at":"2016-03-29T08:57:12Z","updated_at":"2016-03-29T08:57:12Z","body":"It's been a long time since the original post, so not sure what where the roots of the problem back then (but I know what causes it now :smiley:). BTW, if anyone is curious, I put the code into a runnable demo [here][1].\r\n\r\nI'm closing this issue in favor of #14336, where I have described the actual problem (and some background).\r\n\r\n--\r\n@mbarakaja, I am not sure your problem is the same (I am kind of buffled by `time: 109999`).\r\nIf you are confident it is the same issue, then let's track this in #14336. If not, please sublit a new issue providing sufficient details to reproduce the problem (a live demo works best :stuck_out_tongue:).\r\n\r\n[1]: https://codepen.io/ExpertSystem/pen/ZWJYdj?editors=001"}}