What could be causing the Firebase login to return undefined when using the cypress-firebase npm module?

Currently utilizing:

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

Within 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 });

Encountered the following issue when attempting to run the code:

TypeError

The error is within your test code, not Cypress:

> Cannot read property 'initializeApp' of undefined

Answer №1

The Firebase SDK has undergone significant changes with the release of version 9, transitioning to modular and tree-shakeable code. This means that most existing documentation and example code is tailored for versions prior to v8 and may need updates.

To learn more about migrating to the new SDK, click here.

As the current version of cypress-firebase does not yet support the v9 SDK, it is recommended to import the compatibility SDK instead. Keep in mind that while the compatibility SDK is deprecated, it is advised to seek a package that fully supports 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 });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Capture every incoming request with various HTTP methods using nock

Check out the updated intercept function below: interceptWithError() { nock(baseUrl) .get(/.*/) .replyWithError(500); nock(baseUrl) .put(/.*/) .replyWithError(500); nock(baseUrl) .post(/.*/) .replyWithError(500); nock(ba ...

Unexpected behavior in the AngularJS UI Bootstrap datepicker causing dates to shift

Hi there, I have encountered an issue with setting the default date format (YYYY-MM-DD) in the UI Bootstrap datepicker input field using momentjs. Everything seems to display correctly until I try to console log the selected date. It appears that an additi ...

Tips for incorporating CRUD functionality using jQUery

Recently, I successfully created a users list using CRUD with PHP, MySQL, and Bootstrap. Everything was working smoothly. However, I faced some errors when trying to integrate jQuery to avoid page refreshes during operations. Creating/inserting new users ...

Fetching Data from Response Headers in Angular 4.3.3 HttpClient

(Text Editor: Visual Studio Code; TypeScript Version: 2.2.1) The main objective here is to fetch the headers of the response from a request Let's consider a scenario where we make a POST request using HttpClient within a service: import { Injec ...

Popup appears on incorrect page

As part of my app development project, I implemented a popover feature that opens when clicking on a label. Initially, this functioned smoothly within a tab navigation setup. However, after transitioning from tab modules to the app-routing module to displa ...

What could be causing the glitches I'm encountering while attempting to develop a React application with 'create-react-app'?

Recently, I set up my new PC and wanted to start writing React code. After installing npm, the next step was to run npx create-react-app. However, every time I tried, I encountered this error message: $ npx create-react-app code-app npm ERR! code ENOENT np ...

Using .change(); in JavaScript code with jQuery does not trigger a function

Here we have a generic code example for a jQuery function: $(document).ready(function() { if (something) { // This does something } else if (something else) { // This does something else } else { // And this does somethin ...

Issue encountered while executing the "npm run server" directive

The dot '.' is giving an error, saying it is not recognized as an internal or external command, operable program, or batch file. https://i.sstatic.net/CM6OL.png ...

How can I retrieve information from a topic using kafka-node?

Having trouble reading data from a Kafka server? You may encounter an error message stating that the topic does not exist. Here are some questions to guide you: 1- How can I ensure that my Kafka connection is established? 2- What is the process for retri ...

Can you customize the background color for the entire section where the first child appears in a nested collapsible list with CSS?

In my current setup, I have a nested list within a larger container box. Each ul element has a border-top style applied, while each li element has a border-bottom and padding. The HTML code looks like this: <div class="menu"> <ul ...

Leveraging React hooks to combine an array and an object within an array

Struggling to incorporate an array and an object into another array. This is the setup in my constructor: const [dashboard, setDashboard] = useState({ loading: true, data: [], address: '' }) This is how I envision the final data structure: { ...

"Implementing an AngularJS factory that returns a State object instead of typical JSON data fetched from

I have created two factories and I am calling the first one from the second one in my controller. However, instead of receiving JSON data, I am getting data as $$State. I am new to AngularJS and have tried multiple solutions but have not been able to resol ...

Issue with command execution within execSync in node.js

I am facing an issue where a shell command works fine from the terminal, but when I try to run it from node.js, it gives me an error. Original Command awk -v RS='"[^"]*"' '{n+=gsub(/\n/, "&")} END{print n}& ...

Integrate Javascript Chart into Your Rails Application

As a newcomer to Rails, I am attempting to incorporate a JavaScript chart from Highcharts.com into my Rails application. However, I have encountered an issue where the view container remains empty. I have downloaded the package and added it to vendor/asse ...

The function message.react in Discord.js is throwing an error

I have a Discord bot set up for reaction roles. I use IDs to cache the messages that need reactions and make sure the bot reacts with the appropriate emojis before further action. Here is my process for caching the messages: const guild = await client.guil ...

Determine the frequency of form submissions

I am trying to find a way to detect if someone attempts to log in to a website multiple times unsuccessfully, and then redirect them to the forgot password page. I am a bit lost on where to start looking for a solution. My plan is to use jQuery and ajax ...

Error encountered when loading dynamic content using JQuery

My goal is to dynamically load parts of pages into my index. I've tried using load() and ajax, but when I click a button in the loaded code (even if it's empty), the entire page reloads! Why is this happening? I've searched online for hours ...

Tips for retrieving the text enclosed within a <span> tag using jQuery

I am new to jQuery and came across this code online for a questionnaire. I want to save the selected options but I am not sure how to do it. " $.fn.jRadio = function (settings)" What is the purpose of this setting? " var options = $.extend(_de ...

Is it possible to use different node versions for my project and a specific library?

Let me provide you with some background information. My team and I are currently working on migrating MUI v3 to v4 in a reactJs project. We have successfully migrated the project itself, but we encountered some issues when navigating to certain windows th ...

On a smaller screen size, the event listeners I add dynamically are successfully attached using the exact same HTML, however, they fail to attach on a larger screen size

I recently created a small website where I dynamically add code to HTML divs. Once the data is set, I attach click and mouse enter/leave events using the div's ID. The site consists of plain HTML, javascript, and CSS. However, I noticed that when I v ...