Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Wait for browser async 1.5 #14116

Closed
wants to merge 3 commits into from

Conversation

heathkit
Copy link

Makes whenStable() wait for outstanding browser requests asynchronously. If it waits synchronously, it will miss $http calls made in the current digest cycle.

Fixes #13782

I think this would also fix angular/protractor#789

@gkalpak
Copy link
Member

gkalpak commented Feb 23, 2016

(Note to self: This is similar to #13862 and #13869.)

@@ -189,10 +189,35 @@ describe('$$testability', function() {

describe('waiting for stability', function() {
it('should process callbacks immediately with no outstanding requests',
inject(function($$testability) {
inject(function($$testability, $timeout) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of this test looks incorrect now (as nothing gets invoked immediately).

Services such as $location and $http will initiate async calls. Thus,
we need to wrap the call to $browser.notifyWhenNoOutstandingRequest
in $timeout() in order to give any potentially outstanding async calls a
chance to run.

Fixes angular#13782
@heathkit heathkit force-pushed the wait-for-browser-async-1.5 branch from bb8d86b to bfe8af0 Compare March 14, 2016 22:33
@heathkit
Copy link
Author

I made the test description a little clearer since it's no longer really immediate.

expect(callback).toHaveBeenCalled();
runs(function() {
$$testability.whenStable(callback);
$timeout.flush();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed ? Wouldn't $rootScope.$digest() suffice ?

@gkalpak
Copy link
Member

gkalpak commented Mar 21, 2016

@mgiambalvo, sorry for the late response. Could you address my comments (which apply to both tests btw) and ping me ?

TBH, I don't think this would fix angular/protractor#789. Have you tried it (OOC) ?
If you fancy, feel free to try to create an e2e test as well (take a look at #13862 to get an idea how to create an e2e test for Angular's testsuite).

@gkalpak
Copy link
Member

gkalpak commented Jul 15, 2016

I tried this out and verified that it doesn't indeed fix neither #13782 nor angular/protractor#789.

@gkalpak gkalpak closed this Jul 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.