How to unit test an angularjs promise chain using $httpBackend
问题 Using AngularJS, I am trying to unit test a function that makes multiple calls to $http. My test looks something like this: it('traverses over a hierarchical structure over multiple chained calls', function() { myService.traverseTheStuff() .then(function(theAggregateResult) { // ...is never fulfilled }); $httpBackend.flush(); }); Other single-call tests will register the callback passed to .then() and execute it as soon as I call .flush(). The code under test looks something like this.