Setting a timeout on a $http request breaks e2e tests #1472
Comments
I think I found the problem, in the "createHttpBackend" function if timeout is set it will thenuse $browser.defer to execute it, but $browser.defer increases outstandingRequestsCount and is never properly canceled if the request doesn't time out, at least not in e2e tests. The code in question looks like this: if (timeout > 0) {
$browserDefer(function() {
status = -1;
xhr.abort();
}, timeout);
} I've been testing around a bit, and it looks like doing a $browser.defer.cancel when request successfully finishes seems to fix it for e2e tests at least, although I haven't tried it outside of the testrunner yet. I'll see if I can get time to do a proper fix and a pull request. |
Bump. So how did you circumvent this problem? I did following like this:
But I had no dice. Thanks. |
Oh, I circumvented it by not using a timeout at all during testing. |
Now I see! |
As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months. Please try the newest versions of Angular ( Thanks! |
On Angular 1.0.8 my E2E tests are slow when using a timeout in $http calls. |
The tests work without problems if I set a timeout for $http calls when running AngularJS 1.2.0-rc2. |
If you configure $http with a custom timeout e2e tests becomes very slow. A browser.navigateTo takes >30s. It looks like the outstandingRequestsCount isn't decremented properly and it waits the entire timeout before continuing, even though the request got a 200 OK ages ago.
ex.
Do something like:
And a e2e tests like:
The text was updated successfully, but these errors were encountered: