Skip to content

Cannot use Protractor at all; tests hang if database.list() is called #779

Closed

Description

@sdebaun

Protractor tests hang if database.list() is called

Added a comment to #225 but that issue is closed and im not sure if my comment will get it noticed. Apologies for double-posting.

Version info

Angular: latest released

Firebase: latest released

AngularFire: latest released

How to reproduce these conditions

Minimal repro in this repo:
https://github.com/sdebaun/af-protractor-test

Steps to set up and reproduce

ng new
npm install --save angularfire2 firebase
import AngularFireModule in AppModule
add constructor with AngularFire to app.component.ts
ng serve and ng e2e, y voila!

  - Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
While waiting for element with locator - Locator: By(css selector, app-root h1)

Expected behavior

To not have the test timeout waiting for angular

Actual behavior

It times out waiting for angular

Activity

  1. changed the title [-]Protractor tests hang if `database.list()` is called[/-] [+]Cannot use Protractor at all; tests hang if `database.list()` is called[/+] on Jan 17, 2017
  2. davideast commented on Mar 16, 2017

    @davideast
    Collaborator

    @sdebaun From what I understand, Protractor doesn't work great with Web Sockets and therefore the Firebase SDK. Your best option right now is ignoring synchronization. I've spoken with the team about improving things but nothing is planned at the moment. Since this has been awhile, is there anything you have discovered?

  3. blaugold commented on Mar 25, 2017

    @blaugold

    The problem is that the firebase sdk is setting up some long running intervals and timeouts. The database client for example sends a heartbeat every 45 seconds, which you can see in the frames of the WebSocket connection in the network tab of your browser. But just calling firebase.initializeApp sets up a 30 second timeout. Protractor is waiting those timeouts and any work scheduled by them. So any tests relying on these tasks to end will timeout.

  4. andreasonny83 commented on May 24, 2017

    @andreasonny83

    I'm experiencing the same problem. After having spent an entire day trying to figure out why all my Protractor test were failing, I realised that either removing my Firebase service from the project or ignoring synchronization fixed the issue.
    I would really like to have a full Protractor support when using FireBase in my web application.

  5. andreasonny83 commented on May 24, 2017

    @andreasonny83

    Another solution not to loose the Angular integration with Protractor, is to extend the timeout limit. Here my protractor.cong.js

    const { SpecReporter } = require('jasmine-spec-reporter');
    
    exports.config = {
      allScriptsTimeout: 60000,  // allScriptsTimeout is 30s by default
    
      specs: [
        './e2e/**/*.e2e-spec.ts'
      ],
      capabilities: {
        'browserName': 'chrome'
      },
      directConnect: true,
      baseUrl: 'http://localhost:4200/',
      framework: 'jasmine',
      jasmineNodeOpts: {
        showColors: true,
        ScriptTimeoutError: 60000,  // ScriptTimeoutError is 30s by default
        defaultTimeoutInterval: 60000, // defaultTimeoutInterval is 30s by default
        print: function() {}
      },
      beforeLaunch: function() {
        require('ts-node').register({
          project: 'e2e/tsconfig.e2e.json'
        });
      },
      onPrepare() {
        jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
      }
    };
    
  6. jamesdaniels commented on Jun 2, 2017

    @jamesdaniels
    Contributor

    Closing for now as it's not a angularfire2 issue. If there's something the Firebase JS SDK can do to make things more testable please open an issue there.

  7. Maistho commented on Sep 1, 2017

    @Maistho
    Contributor

    @jamesdaniels is it possible to run firebase outside of the angular zone?

    http://www.protractortest.org/#/timeouts#angular

    Seems like blaugold/firebase-rxjs is doing something of the sort.

    I'm not sure if it should or can be a part of angularfire2, or if it should be a part of the SDK.

    Should be related to firebase/firebase-js-sdk#119

  8. JamboBuenna commented on Sep 24, 2018

    @JamboBuenna

    Any updates on this. Being able to run firebase outside of the angular zone would solve so many issues with automation

  9. huan commented on Oct 15, 2018

    @huan

    I ran into this issue too.

    I believe what @blaugold said is right: the protractor is waiting for the angular fire to finish its task in the event loop. And I will also support @Maistho to run firebase outside of the angular zone if it has to keep the setInterval.

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