This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
bug(ngMock): errors thrown to reject promises are not caught #7187
Closed
Description
Request Type: bug
How to reproduce: Include angular and angular-mocks on a page and run this code. Error is printed to the console even though the promise chain is configured to recover from the error.
var inject = angular.injector(['ng', 'ngMock']).invoke
inject(function ($http, $httpBackend) {
$httpBackend.expectGET('http://example.com').respond('foo')
$http.get('http://example.com')
.then(function (result) {
throw new Error('Intentional rejection')
})
.then(null, function (err) {
console.log(err);
})
$httpBackend.flush()
})
Component(s): ngMock
Impact: small
Complexity: medium
This issue is related to:
Detailed Description:
This behavior can be corrected by wrapping a try...catch around the call to callback around line 1124 of angular-mocks, but that breaks 3 $compile tests and I'm not sure what to do with the caught error.
In its current state, unit testing promise chains must be done with ngMockE2E.
Other Comments: