prescottprue/cypress-firebase

Unable to execute tests with Firebase Web SDK 9

alfonsojohan opened this issue · 3 comments

We have a VueJS project using firebase SDK version 9. When I follow the instructions in the README as how to setup cypress-firebase i get the error firebase.initializeApp is undefined. We have another project using firebase SDK version 8 and cypress-firebase works great there.

Further research shows that the v9 SDK no longers uses namespaces. Initialization of the firebase library is now done using modular approach as such:

import { initializeApp } from "firebase/app";

const firebaseConfig = {
   -- snip / firebase config --
};
const app = initializeApp(firebaseConfig);

To Reproduce

  • Create new project using firebase SDK version 9
  • Follow steps in README to setup cypress-firebase
  • Setup login tests using cy.login()
  • Execute tests and observe the error

Expected behavior/code

Firebase Login sucessfully

Also facing the same issue. I'm also trying to set up the service account key to see if that works


admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});```

But i get a webpack compilation error

![image](https://user-images.githubusercontent.com/107503177/198232290-29863cfd-9ca3-4814-aeea-290fdbe588b2.png)

I ran into the same issue. The solution to set the env var SERVICE_ACCOUNT to contain the credentials for the service account you can download from "Project Settings" -> "Service Accounts" in the Firebase console.

Going to close since this appears to be an initialization issue more than an issue with Firebase v9 - examples in docs have been updated about usage with v9. There is a plan to switch to v9 + namespaced imports internally (described in #743), but shouldn't impact current usage with v9