E2e testing with Firestore problems: Failed: script timeout

I am trying to implement some simple e2e tests for my simple little “Monty Python Quiz” app (https://github.com/VictorNorman/ionic-quiz-demo) and keep running into problems.

My test starts up Chrome and I see the data, which has been pulled down from firestore, but then the test dies, not giving me enough information to figure out what is wrong. I think it is only a problem when I use firestore as my data source – instead of using hard-coded and a non-asynchronous data source.

Here is the output from my run:

12:44:31] I/launcher - Running 1 instances of WebDriver
[12:44:31] I/direct - Using ChromeDriver directly...
Jasmine started

  new App
    ✗ should have first page with correct question and answers
      - Failed: script timeout
        (Session info: chrome=81.0.4044.92)
        (Driver info: chromedriver=81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}),platform=Mac OS X 10.15.4 x86_64)
        (Session info: chrome=81.0.4044.92)
        (Driver info: chromedriver=81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}),platform=Mac OS X 10.15.4 x86_64)
          at Object.checkLegacyResponse (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/error.js:546:15)
          at parseHttpResponse (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/http.js:509:13)
          at doSend.then.response (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/http.js:441:30)
          at process._tickCallback (internal/process/next_tick.js:68:7)
      From: Task: Protractor.waitForAngular() - Locator: By(css selector, app-root ion-content)
          at Driver.schedule (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
          at ProtractorBrowser.executeAsyncScript_ (/Users/vtn2/ionic/quiz-orig/node_modules/protractor/built/browser.js:425:28)
          at angularAppRoot.then (/Users/vtn2/ionic/quiz-orig/node_modules/protractor/built/browser.js:456:33)
          at ManagedPromise.invokeCallback_ (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:1376:14)
          at TaskQueue.execute_ (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:3084:14)
          at TaskQueue.executeNext_ (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:3067:27)
          at asyncRun (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:2927:27)
          at /Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:668:7
          at process._tickCallback (internal/process/next_tick.js:68:7)Error:
          at ElementArrayFinder.applyAction_ (/Users/vtn2/ionic/quiz-orig/node_modules/protractor/built/element.js:459:27)
          at ElementArrayFinder.(anonymous function).args [as getText] (/Users/vtn2/ionic/quiz-orig/node_modules/protractor/built/element.js:91:29)
          at ElementFinder.(anonymous function).args [as getText] (/Users/vtn2/ionic/quiz-orig/node_modules/protractor/built/element.js:831:22)
          at AppPage.getParagraphText (/Users/vtn2/ionic/quiz-orig/e2e/src/app.po.ts:8:52)
          at UserContext.<anonymous> (/Users/vtn2/ionic/quiz-orig/e2e/src/app.e2e-spec.ts:14:17)
          at /Users/vtn2/ionic/quiz-orig/node_modules/jasminewd2/index.js:112:25
          at new ManagedPromise (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:1077:7)
          at ControlFlow.promise (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:2505:12)
          at schedulerExecute (/Users/vtn2/ionic/quiz-orig/node_modules/jasminewd2/index.js:95:18)
          at TaskQueue.execute_ (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:3084:14)
      From: Task: Run it("should have first page with correct question and answers") in control flow
          at UserContext.<anonymous> (/Users/vtn2/ionic/quiz-orig/node_modules/jasminewd2/index.js:94:19)
          at /Users/vtn2/ionic/quiz-orig/node_modules/jasminewd2/index.js:64:48
          at ControlFlow.emit (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/events.js:62:21)
          at ControlFlow.shutdown_ (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:2674:10)
          at shutdownTask_.MicroTask (/Users/vtn2/ionic/quiz-orig/node_modules/selenium-webdriver/lib/promise.js:2599:53)
      From asynchronous test:
      Error:
          at Suite.<anonymous> (/Users/vtn2/ionic/quiz-orig/e2e/src/app.e2e-spec.ts:11:3)
          at Object.<anonymous> (/Users/vtn2/ionic/quiz-orig/e2e/src/app.e2e-spec.ts:4:1)
          at Module._compile (internal/modules/cjs/loader.js:776:30)
          at Module.m._compile (/Users/vtn2/ionic/quiz-orig/node_modules/ts-node/src/index.ts:439:23)
          at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
          at Object.require.extensions.(anonymous function) [as .ts] (/Users/vtn2/ionic/quiz-orig/node_modules/ts-node/src/index.ts:442:12)

**************************************************
*                    Failures                    *
**************************************************

1) new App should have first page with correct question and answers
  - Failed: script timeout
    (Session info: chrome=81.0.4044.92)
    (Driver info: chromedriver=81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}),platform=Mac OS X 10.15.4 x86_64)

Executed 1 of 1 spec (1 FAILED) in 12 secs.
[12:44:45] I/launcher - 0 instance(s) of WebDriver still running
[12:44:45] I/launcher - chrome #01 failed 1 test(s)
[12:44:45] I/launcher - overall: 1 failed spec(s)
[12:44:45] E/launcher - Process exited with error code 1

It always gives me this error. I see the web page rendered correctly.

Note that when I comment out the call to initiate connecting to firestore and loading the data from it, then my test passes. E.g., the test passes when in initializeApp() in app.component.ts looks like this:

  initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
//      this.quizDataSvc.loadAllData();
    });
  }

Here is the whole test:

describe('new App', () => {
  let page: AppPage;

  beforeEach(() => {
    page = new AppPage();
  });

  it('should have first page with correct question and answers', () => {
    page.navigateTo();
    expect(page.getParagraphText()).toContain('What is your name?');
  }

getParagraphText() is:

getParagraphText() {
    return element(by.css('app-root ion-content')).getText();
  }

Has anyone successfully implemented e2e testing against Firestore data? There is something about calling firestore that causes my test to timeout.

Thanks.

Vic

Here is my config info:

$ ionic info

Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.803.26
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : not available
   Cordova Plugins   : not available

Utility:

   cordova-res (update available: 0.11.0) : 0.6.0
   native-run (update available: 1.0.0)   : 0.3.0

System:

   Android SDK Tools : 26.1.1 (/Users/vtn2/Library/Android/sdk)
   NodeJS            : v10.16.0 (/usr/local/bin/node)
   npm               : 6.13.7
   OS                : macOS Catalina

I figured out how to fix my problem. For some reason, I needed to put

browser.ignoreSynchronization = true;

into my code.

I don’t know why this is, but it is.

Hope this helps someone else in the future.

1 Like

Thanks! It really helped me. I have a similar scenario as you, as I’m pulling the content from firebase’s remote config. Saved me ton of time.