-
Notifications
You must be signed in to change notification settings - Fork 27.5k
httpBackend's verify methods don't catch unexpected http calls #15855
Comments
It looks like this is related to the error handler in your |
@gkalpak could this be related to the changes in the $q error handling? |
Yes. When there is an unexpected request, If there is an error handler somewhere down the promise chain, then the rejection is passed to that and the handler is responsible for taking over. If there is no error handler though, a Possibly Unhandled Rejection is passed to the |
If we want to restore the previous behavior (which sounds reasonable for the case where there is an unexpected or pending request), then we need to explicitly call |
I would think this invalidates a lot of unit tests around the work that relied on this functionality. I know for us there are now a lot of test passing that should not be without anyone noticing. |
If anyone interested in taking a stab at it, please do 😃 |
my bad, I've been just hitting the original issue |
The unit tests that are meant to catch the issue: |
Just running The PRed change is rather ugly (but it passes proposed tests); the possible improvement would be to have a specific error class that is rethrown by I've tried |
I'm submitting a ...
Current behavior:
Starting in angular 1.6.0, when a unit test exercises an http call but doesn't specify an httpBackend expectation, neither the
httpBackend.verifyNoOutstandingExpectation()
nor thehttpBackend.verifyNoOutstandingRequest()
method throw an error. This problem still manifests in the latest snapshot.Expected / new behavior:
Previously (on angular 1.5.11) each of the verify methods threw errors with the message "Unexpected request: GET No more request expected" when an http method was called without an accompanying expectation.
Minimal reproduction of the problem with instructions:
Write a unit test that exercises a
$http
call but don't tell httpBackend to expect it. CallhttpBackend.verifyNoOutstandingExpectation()
andhttpBackend.verifyNoOutstandingRequest()
and neither of them will throw an error and your test will pass.Plunk on angular snapshot: http://plnkr.co/edit/DZZ2Nl?p=preview
Change the angular version to 1.5.11 and the test will pass.
Angular version: 1.6.3
This is an issue in 1.6.0 through the most recent snapshot of angular. An interesting note is that it is not the version of angular-mocks that makes the difference as I would have expected, but rather the version of core angular.
Browser: [all]
Happens in node/karma/jasmine tests and in Chrome jasmine runner (see plunk)
Anything else:
The text was updated successfully, but these errors were encountered: