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.
Emulator should be able to connect the same way it does when being used in the browser.
yarn installyarn emulatorsyarn seedyarn startlocalhost:3000 in your browser - notice that data loads from both emulated databasesyarn testAt 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:



Happens with all cypress versions including:

@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: trueseems 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,
});
}
Most helpful comment
As noted in https://github.com/cypress-io/cypress/issues/2374 - passing
experimentalForceLongPolling: trueseems 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)