SIGN IN SIGN UP
angular / angular.js UNCLAIMED

AngularJS - HTML enhanced for web apps!

0 0 0 JavaScript

fix(ngMock): trigger digest in `$httpBackend.verifyNoOutstandingRequest()`

Firing a digest at the beginning of the verification process, ensures that requests fired
asynchronously - e.g. in the `resolve` handler of a promise as happens with `$http` - will get
detected as well.
Previously, in order to reliably verify that there was no outstanding request, users needed to
manually trigger a digest, before calling `verifyNoOutstandingRequest()`. Failing to do so, could
prevent `verifyNoOutstandingRequest()` from detecting pending requests and cover bugs in application
code.
This is no longer the case, since a digest will always be fired autommatically as part of a call to
`verifyNoOutstandingRequest()`.

Fixes #13506
Closes #13513

BREAKING CHANGE:

Calling `$httpBackend.verifyNoOutstandingRequest()` will trigger a digest. This will ensure that
requests fired asynchronously will also be detected (without the need to manually trigger a digest).
This is not expected to affect the majority of test-suites. Most of the time, a digest is (directly
or indirectly) triggered anyway, before calling `verifyNoOutstandingRequest()`.
In the unlikely case that a test needs to verify the timing of a request with respect to the digest
cycle, you should rely on other means, such as mocking and/or spying.
K
Kate Miháliková committed
267ee9c892b0eb40908700ee2435793f8c6c1c84
Parent: 859b1e3
Committed by Georgios Kalpakas <kalpakas.g@gmail.com> on 7/13/2016, 6:46:02 PM