Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix: Replacing timeout with interval for compatibility with Protractor #2798

Closed
wants to merge 1 commit into from

Conversation

moses-seeq
Copy link

In order to test an application that includes the datepicker using Protractor, $timeout has been replaced with $interval. In the case of datepicker, this was a small, straightforward change.

Splaktar pushed a commit to Splaktar/bootstrap that referenced this pull request Oct 27, 2014
@chrisirhc
Copy link
Contributor

That's odd, this looks like it shouldn't matter since using an $interval once should be equivalent to using the $timeout service. Isn't it?

@moses-seeq
Copy link
Author

Yes on the surface, but Protractor waits for any $timeout calls to finish in an attempt to avoid syncing problems. As a result, Protractor tests fail due to timing out. Given that Protractor is the recommended end to end testing framework for AngularJS applications, this simple change is worthwhile.

@chrisirhc
Copy link
Contributor

I understand compatibility with Protractor is important. That's why I'm trying to understand the issue here.
If this shouldn't change to $interval, shouldn't all $timeout calls need to be changed to $interval? That doesn't seem to make sense.

I don't understand how Protractor won't just be waiting for one $timeout call in this case? It should only fail if this $timeout creates another $timeout and it doesn't end.

@moses-seeq
Copy link
Author

Yes, all $timeout calls need to be changed to $interval. I changed the ones in datepicker only, as that is what we are using and that is what I could easily test. I am surprised that Protractor would fail as a result as well, but this one changed fixed the issue we were seeing and the change is consistent with recommendations elsewhere.

@chrisirhc
Copy link
Contributor

I'm looking at https://github.com/angular/protractor/blob/master/docs/timeouts.md . There it mentions polling tasks should be changed to use the interval service. Which error are you running into and what kind of test? Could you provide an example for datepicker so we can investigate this for other directives?

@vlajos
Copy link

vlajos commented Jul 21, 2015

I had the same issue with alert. And applied a similar fix: #3982
There is a bit more background: angular/protractor#169 (comment)

If you agree with this new approach, I can help to port $timeouts to $interval. (Let me know.)

@Foxandxss
Copy link
Contributor

We decided that this bug should be fixed in protractor and not here. Closing this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants