@@ -1323,7 +1323,7 @@ angular.mock.dump = function(object) {
1323
1323
```
1324
1324
*/
1325
1325
angular . mock . $httpBackendDecorator =
1326
- [ '$rootScope' , '$timeout' , '$delegate' , createHttpBackendMock ] ;
1326
+ [ '$q' , '$ rootScope', '$timeout' , '$delegate' , createHttpBackendMock ] ;
1327
1327
1328
1328
/**
1329
1329
* General factory function for $httpBackend mock.
@@ -1339,7 +1339,7 @@ angular.mock.$httpBackendDecorator =
1339
1339
* @param {Object= } $browser Auto-flushing enabled if specified
1340
1340
* @return {Object } Instance of $httpBackend mock
1341
1341
*/
1342
- function createHttpBackendMock ( $rootScope , $timeout , $delegate , $browser ) {
1342
+ function createHttpBackendMock ( $q , $ rootScope, $timeout , $delegate , $browser ) {
1343
1343
var definitions = [ ] ,
1344
1344
expectations = [ ] ,
1345
1345
responses = [ ] ,
@@ -1438,10 +1438,15 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1438
1438
return ;
1439
1439
}
1440
1440
}
1441
- throw wasExpected ?
1442
- new Error ( 'No response defined !' ) :
1443
- new Error ( 'Unexpected request: ' + method + ' ' + url + '\n' +
1441
+ var error = wasExpected ?
1442
+ new $q . $$PassToExceptionHandlerError ( 'No response defined !' ) :
1443
+ new $q . $$PassToExceptionHandlerError ( 'Unexpected request: ' + method + ' ' + url + '\n' +
1444
1444
( expectation ? 'Expected ' + expectation : 'No more request expected' ) ) ;
1445
+
1446
+ // In addition to be being converted to a rejection, this error also needs to be passed to
1447
+ // the $exceptionHandler and be rethrown (so that the test fails).
1448
+
1449
+ throw error ;
1445
1450
}
1446
1451
1447
1452
/**
@@ -2706,7 +2711,7 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
2706
2711
*/
2707
2712
angular . mock . e2e = { } ;
2708
2713
angular . mock . e2e . $httpBackendDecorator =
2709
- [ '$rootScope' , '$timeout' , '$delegate' , '$browser' , createHttpBackendMock ] ;
2714
+ [ '$q' , '$ rootScope', '$timeout' , '$delegate' , '$browser' , createHttpBackendMock ] ;
2710
2715
2711
2716
2712
2717
/**
0 commit comments