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

Firestore emulator does not work in Cypress #1975

Closed
prescottprue opened this issue Feb 14, 2020 · 4 comments
Closed

Firestore emulator does not work in Cypress #1975

prescottprue opened this issue Feb 14, 2020 · 4 comments
Labels
Needs: Author Feedback Issues awaiting author feedback

Comments

@prescottprue
Copy link

[REQUIRED] Environment info

firebase-tools: 7.13.0

Platform: macOS

[REQUIRED] Test case

  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

You should see projects from Firestore and RTDB appear in the view. This is expected - the next section covers what is unexpected

[REQUIRED] Steps to reproduce

  1. Follow the previous section
  2. In another terminal window, open the test runner by running: yarn test
  3. 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

[REQUIRED] Expected behavior

The expected behavior is that the Firestore emulator works within a browser window Cypress the same way it does in a normal browser - the same way RTDB emulator works

An issue was also filed on the Cypress Repo

[REQUIRED] Actual behavior

Connecting to the Firestore emulator within browser window opened by 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:

image

Happens in both Chrome and Electron

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

@samtstern
Copy link
Contributor

I am not familiar with Cypress, but is there something here that leads you to believe this is an issue with the Firebase emulators or the Firebase CLI? Can you see network traffic going out to the right host/port but the emulators not responding? To my (untrained) eye it seems like the issue is likely to be inside Cypress since this works in a "standard" web testing setup.

@samtstern samtstern added the Needs: Author Feedback Issues awaiting author feedback label Feb 14, 2020
@ppalyga
Copy link

ppalyga commented Feb 15, 2020

I also run into the same problem, having the newest version of Java and Cypress 4.0.2 installed. I was able to make it work by using experimentalForceLongPolling: true flag in firestore.settings.

@wvanderdeijl
Copy link
Contributor

That is the same workaround we are using in cypress. I think the underlying problem is that Cypress is intercepting all network traffic so it can monitor and sometimes mock. However, the webchannel protocol used by firestore has multiple replies over the same http request. The Cypress code cannot handle this and will only forward the first reply and ignore the rest.
For more info see cypress-io/cypress#2374

@samtstern
Copy link
Contributor

@wvanderdeijl thanks for pointing this out! Since Cypress is intercepting all network requests we can't support any issues caused by that. So I am going to close this in favor of looking for a solution from the Cypress team over at cypress-io/cypress#2374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Issues awaiting author feedback
Projects
None yet
Development

No branches or pull requests

4 participants