title: How to implement intervals/polling in angular2 to work with protractor?
body: <p>I have an angular2 app I want to test with protractor.</p>
  
  <p>In this app I have a page with a graph that is being updated in regular intervals with autogenerated data.</p>
  
  <p>Apparently one feature of protractor is waiting for scripts and http calls to finish before executing test code. However, if there is a constantly polling script that never finishes, protractor will wait forever and time out after a certain time.</p>
  
  <p>In angular1 this could be solved by implementing the polling with <code>$interval</code>, which protractor does not wait for. Unfortunately in angular2 there is no <code>$interval</code> and the correct way to implement polling seems to be <code>Observable.interval</code>, so this is what my code looks like:</p>
  
  <pre><code>Observable.interval(500)
            .map(x =&gt; this.getRandomData())
            .subscribe(data =&gt; this.updateGraph(data));
  </code></pre>
  
  <p>When testing a page where this code is running, protractor will time out. It waits for the page to finish loading and thinks this script will exit sometime (when in fact it runs forever).</p>
  
  <ul>
  <li><p>Is there an interval mechanism in angular2 that protractor recognizes, so that it doesn't wait for the polling to finish before running the UI tests?</p></li>
  <li><p>If not, how can I tell protractor not to wait for this interval to finish before executing more test code?</p></li>
  </ul>
  
  <p>EDIT: To clarify, the timeout problem already existed in protractor with angular1, but could be fixed by using <code>$interval</code>, see: </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/28907351/timed-out-waiting-for-protractor-to-synchronize-with-the-page-after-50001ms/28969956#28969956">Timed out waiting for Protractor to synchronize with the page after 50001ms</a></li>
  <li><a href="https://stackoverflow.com/questions/31414312/how-to-implement-intervals-in-protractor-selenium">How to implement intervals in protractor/selenium</a></li>
  </ul>
  
  <p>This doesn't work in angular2 because there is no <code>$interval</code>.</p>