Cypress: Cannot connect to Firestore emulator

Created on 6 Feb 2020  路  6Comments  路  Source: cypress-io/cypress

Current behavior:

Connecting to the Firestore emulator within Cypress does work the way it does in a default browser. When attempting to open the app in cypress it shows the "Could Not reach Firestore backend" error.
Here is a sample repo showing the issue - instructions to reproduce are in the README.

When connecting normally in the browser, data is loaded from both the Real Time Database and Firestore emulators.

This issue has also been mentioned by another user in this stackoverflow post.

Desired behavior:

Emulator should be able to connect the same way it does when being used in the browser.

Test code to reproduce


  1. Pull this sample repo
  2. Run yarn install
  3. As described in the README run the following:

    1. Start the emulators: yarn emulators

    2. In a new terminal window, seed the emulated databases with data: yarn seed

    3. Start the app by running: yarn start

    4. Visit localhost:3000 in your browser - notice that data loads from both emulated databases

    5. In another terminal window, open the test runner by running: yarn test

    6. Run the projects tests by clicking on "Projects.spec.js"

At this point the data does not load from the Firestore emulator within Cypress even though they will load in the browser (pictured below). This error appears in the console of the window opened by Cypress:
image

image

image

Versions


Happens with all cypress versions including:

  • 3.8.3 - chrome and electron
  • 4.0.1 - chrome and electron

Most helpful comment

As noted in https://github.com/cypress-io/cypress/issues/2374 - passing experimentalForceLongPolling: true seems to make things work even in the provided repro.

That said, I don't think that is a good long term solution since it may be removed at some point (as noted in this issue on the Firebase JS SDK). It think it would be best to have full documentation around how this is handled in Cypress and ways to debug webchannel traffic in general (since Firestore is probably not the only setup like this)

All 6 comments

Screen Shot 2020-02-10 at 12 26 01 PM

@jennifer-shehane Are you just making note of that? I have java installed and running fine on my end. As shown above - things render fine in the normal browser, just not the one spun up by Cypress.

@jennifer-shehane Are you just making note of that? I have java installed and running fine on my end. As shown above - things render fine in the normal browser, just not the one spun up by Cypress.

Since I am also having this issue I was wondering if it could be related to the Java version because I installed mine from brew. Have you done the same?

@AugustinGrigorov I believe I installed just from a manual download, but not positive, it could have been brew. I am running Java 10.0.2

As noted in https://github.com/cypress-io/cypress/issues/2374 - passing experimentalForceLongPolling: true seems to make things work even in the provided repro.

That said, I don't think that is a good long term solution since it may be removed at some point (as noted in this issue on the Firebase JS SDK). It think it would be best to have full documentation around how this is handled in Cypress and ways to debug webchannel traffic in general (since Firestore is probably not the only setup like this)

As noted in #2374 - passing experimentalForceLongPolling: true seems to make things work even in the provided repro.

That said, I don't think that is a good long term solution since it may be removed at some point (as noted in this issue on the Firebase JS SDK). It think it would be best to have full documentation around how this is handled in Cypress and ways to debug webchannel traffic in general (since Firestore is probably not the only setup like this)

Thanks, this works for me.

const db = firebase.firestore();

if (location.hostname === "localhost") {
  db.settings({
    experimentalForceLongPolling: true,
  });
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

weskor picture weskor  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

brian-mann picture brian-mann  路  3Comments

zbigniewkalinowski picture zbigniewkalinowski  路  3Comments

stormherz picture stormherz  路  3Comments