From 8502070fff6694053718347c168205f0320390a0 Mon Sep 17 00:00:00 2001 From: Marcin Wosinek Date: Sun, 6 Aug 2017 19:55:30 +0100 Subject: [PATCH] fix($httpBackend): ugly solution for unexpected request fail on verify no outstanding request --- src/ng/q.js | 4 ++++ src/ngMock/angular-mocks.js | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ng/q.js b/src/ng/q.js index c2fb12361c29..b4dca7999a2b 100644 --- a/src/ng/q.js +++ b/src/ng/q.js @@ -364,6 +364,10 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) { } } catch (e) { rejectPromise(promise, e); + // TODO ugly! + if (e.rethrow === true) { + exceptionHandler(e); + } } } } finally { diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 3416448b40b6..8f9615a390ac 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -1438,10 +1438,15 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) { return; } } - throw wasExpected ? + var error = wasExpected ? new Error('No response defined !') : new Error('Unexpected request: ' + method + ' ' + url + '\n' + (expectation ? 'Expected ' + expectation : 'No more request expected')); + + // TODO ugly! + error.rethrow = true; + + throw error; } /**