Comments (6)
Here is an example of what I was mentioning with firebase-tools-extra:
#!/bin/sh
# NOTE: firebase-extra is used since firebase-tools doesn't currently support emulators (see https://github.com/firebase/firebase-tools/issues/1957)
# NOTE: Make sure to set FIRESTORE_EMULATOR_HOST and FIREBASE_DATABASE_EMULATOR_HOST to environment to use emulators
echo "Seeding DB..."
# Update data in firestore with inline data
firebase-extra firestore:set /users/ABC123 -d '{"some": "data"}' && echo "Updated user in firestore"
# Seed data to RTDB from a file
firebase-extra database:update /roles ./data/roles.json && echo "Set roles from file"
echo "Successfully seeded databases"
Notice how you can pass a file path or stringified data if you use the -d
flag, just like the firebase-tools API
from cypress-firebase.
Of note: as of firebase-tools v8.5.0 there is now support for using --import
with RTDB
from cypress-firebase.
And v8.6.0 adds --export-on-exit
. Things in FB Emulator space are maturing!
from cypress-firebase.
I could see this being a feature for sure, but something to keep in mind is that if this is planned to be used for cleanup, like you were mentioning, that may not always get run depending on where the logic is placed. Also, Cypress advocates for only cleaning up when absolutely necessary as mentioned in their Best Practices docs
Something else is that the hope would be that folks aren't creating logic/cloud functions just for cleaning up after tests, but instead testing on an environment that either doesn't need to get cleaned up or is cleaned on some schedule outside of testing. For my team we have most tests run against an emulated environments with the cloud functions actually not emulated so that we can confirm data is written to the DB correctly, then handle testing functions in their own unit tests. This has helped make UI tests less flaky since we aren't waiting on a full round trip, that said, it is more of an "integration" approach rather than full "end to end"
from cypress-firebase.
I agree with 98% of the Cypress best practices. Some of their best practices assume a db that can be simply cleared and restored. There is friction when it comes to working with a more rigid environment like Firebase. Firebase Auth, in particular, don't work that way 😄
I'm not looking to tear down & build up the environment with every single test run. But even the one-time setup needs to be automated for consistency. Adding dozens of users, their roles, their groups....don't want to do that manually. And I don't want to share my dev & test environments with others.
from cypress-firebase.
That is fair, I definitely feel you there! Something to note though is that firebase-tools does have import capability for the Firestore emulator (through the --import flag when booting up emulator with emulators:exec
or emulators:start
as well as for auth (auth import/export). Also, if you are looking to seed RTDB with data, my team has been using firebase-tools-extra which uses the same API as firebase-tools, but has support for talking to RTDB and Firestore emulators
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 🚨
- Cypress Firebase in Github Actions cannot find `CYPRESS_TEST_UID` from secrets.CYPRESS_TEST_UID HOT 1
- 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.