-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Consider allowing e2e test to ignore certain timeouts #14118
Comments
1: Instead of waiting for there to be 0 timeouts, the test writer could pass in a number X, and we could wait for there to be <= X. Although this would be easy to implement, I think this would not work in enough cases that it is not worth investing time in as a complete solution. Moreover it is fragile in the case that someone adds a new unexpected timeout that basically breaks unrelated tests. 2: We could add yet another parameter to $timeout telling angular to ignore it for reporting stability While this is a nice option in itself, we already have a heavily overloaded 3: We could add some ability to name your timeouts, and let protractor pass in a list of timeouts it should ignore. Concerns here: name conflicts, names getting minified. If we could work around the minification issue then this would be neat, since it is good practice to name your functions from a debugging point of view. |
You could exclude the names from minification in a built-step. Would be a bit of a hassle, but not too problematic. |
@Narretz : By "exclude" did you mean "extract"? |
I don't think that introducing new build steps is a reasonable default recommendation - there are lots of different build systems and we can't have a preset solution for all of them. The only way to really do this generally would be to have the names a string constants. |
So, I list a few cases that we would want to support ideally (feel free to add more):
|
After looking into it a little more, I believe that (3) is covered by Also, (for most cases) (2a) and (2b) can also be achieved with timely use of I believe that many issues people are running into, stem from the improper use of The obvious thing to do is to improve the documentation of Another option to make this easier for people to take advantage of, would be to expose a method on /* Code run here waits for sync */
protractor.ignoreSynchronization(function () {
/* Code run here does not wait for sync */
});
/* Code run here waits for sync */ And we still don't have a good story for (1). FWIW, I think we could add support in Angular's testability to wait for specific asynchronous event types. This would allow more flexibility for (2a)/(2b) and not require extra plugins. // Wait for everything. The same as what we have now (so it's backwards compatible)
$$testability.whenStable(callback);
// Wait for $http requests only. Ignore $timeouts or other stuff.
$$testability.whenStable('http', callback);
// Wait for $timeouts only. Ignore $http requests or other stuff.
$$testability.whenStable('timeout', callback);
// Wait for X and Y event types only. Ignore other stuff.
$$testability.whenStable(['X', 'Y'], callback); Then Protractor should expose an API for the users to specify what they care to wait for at a given point. |
|
Types of async events. Right now I think we only track $http and $timeout, but in the future we might decide to track other stuff or let users register their async operations under a custom namespace. |
I see. I wasn't sure if you meant named timeouts or https requests to particular urls |
I agree that step 1 should be improving the current docs. |
FWIW, Protractor aside, I believe that augmenting the API to allow users to specify "types" of deferred tasks is quite powerful, as it allows them to use non-Angular APIs, but still integrate with Angular's sense of "stability". (This would also provide a way to solve issues such as #13862 or #14116.) E.g. one could do (imaginary APIs): $browser.$incOutstandingRequestCount('http');
mySocketConnection.onmessage = function (event) {
$browser.$completeOutstandingRequest('http', function() {
// Do some stuff with `event` first
});
};
mySocketConnection.send('You there, server?') |
@juliemr what do you think? |
@gkalpak there's a problem that's not covered by We could potentially do the thing where we add more arguments to (you're totally right, we should improve docs for ignoreSynchronization. We want to re-do it so we've been putting that off). |
Based on a discussion we had about angular/protractor#2950. Since this feature would require changes to Angular.js, moving discussion here.
The basic problem is that sometimes, apps have a long-running or repeating
$timeout
call for some reason. Protractor waits for all timeouts to finish before reporting stable, so this causes it fail for any tests on that page.An example use case would be a page using a widget that they don't necessarily control the code for, which has a long running
$timeout
. Ideally, they'd be able to ignore this timeout without changing the code for the widget.Mitigating, currently available solutions:
browser.ignoreSynchronization = true
or by directly usingbrowser.driver.<method>
$interval
instead of$timeout
Potential solutions that would require changes to angular:
<= X
.$timeout
telling angular to ignore it for reporting stability (note that this requires some changes to the app code)The text was updated successfully, but these errors were encountered: