Skip to content

bug(testability): scheduling a task with setInterval causes angular to be seen as unstable indefinitely #8089

Closed

Description

@sjelin

When you use setInterval, zone.js will count that as a pending task, and then will not decrease the pending task count until the event is canceled. The result is that if you use setInterval, then zone.js will think itself unstable until the interval is cleared. This is a reasonable design choice, but the problem is that we then wait on zone.js to be stable in the testability API. So if an app uses setInterval without the intention ever clearing the interval, the app will forever be seen as unstable by the testability API. This is clearly wrong, leading some protractor tests to hang. I propose that the testability API wait only on non-periodic tasks.

Activity

  1. sjelin commented on Apr 15, 2016

    @sjelin
    ContributorAuthor

    Minimal(ish) reproduction:

    describe('async angular2 application', function() {
      it('should work with setInterval', function() {
        browser.get('/ng2/#/async');
        $('#periodicIncrement .action').click();
        browser.waitForAngular();
      });
    });

    This is a protractor spec against our ng2 testapp. I tried just doing an executeScript instead of clicking on an element but that didn't work, presumably because it wasn't being executed within an angular component.

  2. juliemr commented on Apr 25, 2016

    @juliemr
    Contributor

    This is working as intended - you should run the setInterval outside of the Angular zone. We should make sure that we have good documentation for this.

  3. juliemr commented on Apr 25, 2016

    @juliemr
    Contributor

    See instead #8219

  4. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions