0

I'm using

"cypress-firebase": "^2.0.0",
"firebase-admin": "^9.11.1"

In my cypress command.js file:

import firebase from "firebase/app";
import "firebase/auth";
import "firebase/database";
import "firebase/firestore";
import { attachCustomCommands } from "cypress-firebase";

const fbConfig = {
}

firebase.initializeApp(fbConfig);

attachCustomCommands({ Cypress, cy, firebase });

When I try to execute the code, I face the following issue:

TypeError

The following error originated from your test code, not from Cypress:

> Cannot read property 'initializeApp' of undefined

1 Answer 1

1

In v9 of the Firebase SDK the API surface changed to using modular, tree-shakeable code. Expect pretty much every piece of documentation or example code you see to have been written for v8 or older Firebase SDK versions that need updating.

Read more about migrating here.

Because cypress-firebase has not yet been updated to support the v9 SDK, you need to import the compatibility SDK instead. Note that the compatibility SDK is deprecated and ideally you should find a package that has been updated to support v9.

import firebase from "firebase/compat/app";
import "firebase/compat/auth";
import "firebase/compat/database";
import "firebase/compat/firestore";
import { attachCustomCommands } from "cypress-firebase";

const fbConfig = {
}

firebase.initializeApp(fbConfig);

attachCustomCommands({ Cypress, cy, firebase });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.