Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sdebaun opened this issue Jan 17, 2017 · 8 comments
Closed

Comments

@sdebaun
Copy link

sdebaun commented Jan 17, 2017

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

@sdebaun sdebaun changed the title Protractor tests hang if database.list() is called Cannot use Protractor at all; tests hang if database.list() is called Jan 17, 2017
@davideast
Copy link
Member

@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?

@blaugold
Copy link

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.

@andreasonny83
Copy link

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.

@andreasonny83
Copy link

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 } }));
  }
};

@jamesdaniels
Copy link
Member

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.

@Maistho
Copy link
Contributor

Maistho commented Sep 1, 2017

@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

@JamboBuenna
Copy link

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

@huan
Copy link

huan commented Oct 15, 2018

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants