cypress-firebase
cypress-firebase copied to clipboard
Problem with Token
I am trying to write a test for my firebase based login. In the first instance I installed the version 2.2.5 as suggested here #788.
Following the documentation I have my serviceAccount.json and cypress.config.ts in the project root.
Some code snippet here:
cypress.config.ts
import { defineConfig } from "cypress";
import adimn from "firebase-admin";
import { plugin as cypressFirebasePlugin } from "cypress-firebase";
export default defineConfig({
e2e: {
baseUrl: "http://localhost:3000",
setupNodeEvents(on, config) {
return cypressFirebasePlugin(on, config, adimn);
},
},
});
cypress/support/command.ts
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 = {
// my configuration
};
const namedApp = firebase.initializeApp(fbConfig, "my_app_name");
attachCustomCommands({ Cypress, cy, firebase, app: namedApp });
I wrote two tests. The first is the one suggested by the documentation to confirm things are working:
cypress/e2e/hello-firebase.cy.js
describe("Some Test", () => {
it("Adds document to test_hello_world collection of Firestore", () => {
cy.callFirestore("add", "test_hello_world", { some: "value" });
});
});
And here everything works as expected.
cypress/e2e/test-login.cy.js
describe("Home", () => {
it("login and view listof people", () => {
cy.visit("/login");
cy.login("MY_USER_ID");
cy.get('[data-cy="submit"]').click();
// get something in page
});
});
This snippet run without runtime error but doesn't work as i expect because i'm not logging into the system. The problem i encountered is that the token is never set, instead the user does, inside the local storage.
Screen of the test execution:
Screen of the local storage contents:
Packages version:
"firebase": "^9.20.0", "firebase-admin": "^11.7.0", "cypress": "^12.10.0", "cypress-firebase": "2.2.5"
@bartyx1993 did you find a solution or the root cause for this?
@bartyx1993 did you find a solution or the root cause for this?
No I'm sorry.