Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Token #915

Open
bartyx1993 opened this issue Apr 26, 2023 · 2 comments
Open

Problem with Token #915

bartyx1993 opened this issue Apr 26, 2023 · 2 comments

Comments

@bartyx1993
Copy link

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:

Screenshot 2023-04-26 alle 15 34 04

Screen of the local storage contents:

Screenshot 2023-04-26 alle 15 37 21

Packages version:

"firebase": "^9.20.0",
"firebase-admin": "^11.7.0",
"cypress": "^12.10.0",
"cypress-firebase": "2.2.5"

@ghost
Copy link

ghost commented May 4, 2023

@bartyx1993 did you find a solution or the root cause for this?

@bartyx1993
Copy link
Author

@bartyx1993 did you find a solution or the root cause for this?

No I'm sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant