Comments (13)
Did you end up finding a solution?
from cypress-firebase.
@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.
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.
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.
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.
The yielded output form above exactly comes after the promise by the "then" like you can see here.
from cypress-firebase.
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.
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.
@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.
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.
Closing due to no repro in v1. If anyone is still experiencing this, please reach out
from cypress-firebase.
I'm experiencing this. Cypress ^11.0.1
from cypress-firebase.
@dmytrobasiukqa Could you provide steps to replicate or a repo?
from cypress-firebase.
Related Issues (20)
- publish-npm failing Error: Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 1
- bug: cannot read properties of undefined (reading 'includes') HOT 4
- Login after a logout happening the application fails
- Cypress e2e test fails initialization HOT 1
- feat(build): native esm support
- fix: drop support for node pre 16 HOT 2
- Support passing user claims to cy.login() ? HOT 1
- Invalid options types are ignored, rather than erroring
- The automated release is failing 🚨
- bug(docs): README.md setup is not clear about service account HOT 6
- Retry on 401
- bug(firestore): FieldValue.delete() not handled correctly HOT 3
- feat(callFirestore): ability to use batch writes
- bug(firestore): nested Timestamp value not persisting HOT 3
- bug: callFirestore not recognized in NextJS test HOT 1
- feat: support for component testing
- feat: switch to modular firebase sdks internally HOT 2
- bug(core): Webpack error when running cypress tests with cypress-firebase HOT 10
- callFirestore task fails when running in the CI with message "PERMISSION_DENIED: Missing or insufficient permissions." HOT 1
- Problem with Token HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cypress-firebase.