Skip to content

E2E test with Cypress  #390

@yuucha

Description

@yuucha

The following settings are required in Store to enable access to the emulator, When E2E test with Cypress.

Firebase.firestore().settings({ experimentalForceLongPolling: true });
When performing E2E testing in Cypress, there seems to be a limited number of places to describe.

I thought I could just refer to the setup documentation and describe the settings, but "experimentalForceLongPolling" is not enabled.

In case it is not enabled

if (process.env.NODE_ENV != "production") {
    // NOTE: do NOT put this in production.
    // Cloud Functions is able
    Firebase.firestore().settings({ experimentalForceLongPolling: true });
    Firebase.auth().useEmulator("http://localhost:9099/");
    Firebase.storage().useEmulator('localhost', 9199);
    Firebase.firestore().useEmulator('localhost', 8081);
    Firebase.functions().useEmulator("localhost", 5001);
  }

This description gives a firebase permission error in Cypress.

FirebaseError
The following error originated from your application code, not from Cypress. It was caused by an unhandled promise rejection.

  > Missing or insufficient permissions.

Cypress is worked in the production envroiment.
if you see the parameter of process.env.NODE_ENV, it works in production.

Therefore, create the .env under the root and write it.
VUE_APP_EMULATE=true

If enabled

if (process.env.VUE_APP_EMULATE) {
    Firebase.firestore().settings({ experimentalForceLongPolling: true })
    Firebase.auth().useEmulator("http://localhost:9099/");
    Firebase.storage().useEmulator('localhost', 9199);
    Firebase.firestore().useEmulator('localhost', 8081);
    Firebase.functions().useEmulator("localhost", 5001);
  }

This method solves the problem and I have no problem with it, but if anyone else is having trouble, please refer to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions