-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Conversation
@@ -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) { |
There was a problem hiding this comment.
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
bb8d86b
to
bfe8af0
Compare
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(); |
There was a problem hiding this comment.
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 ?
@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) ? |
I tried this out and verified that it doesn't indeed fix neither #13782 nor angular/protractor#789. |
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