Code Monkey home page Code Monkey logo

Comments (13)

stijnvanlieshout avatar stijnvanlieshout commented on June 12, 2024 5

I'm facing the same issue:
Screenshot 2019-07-28 at 22 47 21

Did you end up finding a solution?

from cypress-firebase.

prescottprue avatar prescottprue commented on June 12, 2024

@Florian007 When calling login, a custom token is generated and passed to the window, but it is still up to your application code to take that custom token and login through Firebase.
Make sure you have the following (from fireadmin as an example)

Add this in your create store file, so that you can initialize from an instance passed to the window (what calling login does)

// Initialize Firebase only if an fbInstance was not passed to the window (tests)
if (!window.fbInstance) {
  firebase.initializeApp(fbConfig)
}

Then later on handle passing of the window.fbInstance within your enhancers (that is if you are not on the next version of react-redux-firebase or the alpha version of redux-firestore, which don't use store enhancers):

const middleware = []

const store = createStore(
  rootReducer,
  initialState,
  compose(
    reactReduxFirebase(window.fbInstance || firebase, combinedConfig),
    reduxFirestore(window.fbInstance || firebase),
    applyMiddleware(...middleware),
  )
)

Hopefully that solves it for you since the fbInstance will will be authorized and be passed to your application. Reach out if it doesn't.

I am realizing now though that this isn't documented anywhere in the setup, so I'm going to look into adding that. Thanks for reporting!

from cypress-firebase.

Florian007 avatar Florian007 commented on June 12, 2024

The complete Error:
Error: CypressError: cy.exec('npx firebase database:set /projects/ABC123 [object Object] -P XXXXXXXX -y') failed because the command exited with a non-zero code.

Pass {failOnNonZeroExit: false} to ignore exit code failures.

Information about the failure:
Code: 2

Stderr:
(node:79996) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.

from cypress-firebase.

Florian007 avatar Florian007 commented on June 12, 2024

Thank you for your fast answer. But I don't really have a Store. I'm using it only in a cypress Test which I've now updated with your fbInstance Test.

import firebase from "firebase/app"
import "firebase/auth"
import "firebase/database"
import "firebase/firestore"
import { fbConfig } from "../../support/commands"

describe("Firebase RDB Save", () => {
before(() => {
// Login using custom token
cy.login()
// Go to account page
cy.visit("/settings")

// Initialize Firebase only if an fbInstance was not passed to the window (tests)
if (!window.fbInstance) {
  firebase.initializeApp(fbConfig)
}

})

it("Should save in Rdb", () => {
const fakeProject = { some: "data" }
cy.callRtdb("set", "projects/ABC123", fakeProject)
})
})

And my support/commands.js looks like:

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

export const fbConfig = {
XXXXXXXXXXX
}

window.fbInstance = firebase.initializeApp(fbConfig)

attachCustomCommands({ Cypress, cy, firebase })

But also with the window.fbInstance Test I get the same error.

Could it have to do with what's mentioned in the cypress error:
Pass {failOnNonZeroExit: false} to ignore exit code failures.

Thank you in advance!

from cypress-firebase.

Florian007 avatar Florian007 commented on June 12, 2024

If I add the failOnNonZeroExit option to your command in attachCustomCommands.js the error goes away.
cy.exec(rtdbCommand, { failOnNonZeroExit: false })

But I then get in cypress on the exec command:
Yielded:
{stdout: "", stderr: "env: node: No such file or directory", code: 127}

from cypress-firebase.

Florian007 avatar Florian007 commented on June 12, 2024

The yielded output form above exactly comes after the promise by the "then" like you can see here.

bildschirmfoto 2019-02-02 um 23 07 08

from cypress-firebase.

prescottprue avatar prescottprue commented on June 12, 2024

Hmm... The code I provided to initialize from an existing instance can be used without redux (store), but belongs in your application code not the tests. Are you able to share your project code? It may be easier to try to debug with the whole setup

from cypress-firebase.

Florian007 avatar Florian007 commented on June 12, 2024

I've created a Testproject (temporarely with a Test Firebase Account). Infos in the README.md
Clone it with:
git clone [email protected]:Florian771/cypress-firebase-test.git

Thanks for watching!

from cypress-firebase.

mattvukas avatar mattvukas commented on June 12, 2024

@stijnvanlieshout I can confirm that I only get this error on Node v12. On Node v10.16.3 (latest LTS version, I no longer get the "Setting the NODE_TLS_REJECT_UNAUTHORIZED..." error.

Otherwise, I am still running into Firestore query permissions issues in our app, even when using the aforementioned window.fbInstance || firebase setup when initializing things.

from cypress-firebase.

prescottprue avatar prescottprue commented on June 12, 2024

Are folks still experiencing this as an issue with cypress 4.2.0 and cypress-firebase v1.0.0?

v1.0.0 works using tasks and firebase-admin instead of calling through firebase-tools-extra

from cypress-firebase.

prescottprue avatar prescottprue commented on June 12, 2024

Closing due to no repro in v1. If anyone is still experiencing this, please reach out

from cypress-firebase.

dmytrobasiukqa avatar dmytrobasiukqa commented on June 12, 2024

I'm experiencing this. Cypress ^11.0.1

from cypress-firebase.

prescottprue avatar prescottprue commented on June 12, 2024

@dmytrobasiukqa Could you provide steps to replicate or a repo?

from cypress-firebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.