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.
Angular: latest released
Firebase: latest released
AngularFire: latest released
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)
To not have the test timeout waiting for angular
It times out waiting for angular
@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?
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.
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.
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 } }));
}
};
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.
@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 https://github.com/firebase/firebase-js-sdk/issues/119
Any updates on this. Being able to run firebase outside of the angular zone would solve so many issues with automation
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.
Most helpful comment
@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 https://github.com/firebase/firebase-js-sdk/issues/119