firebase-tools
                                
                                
                                
                                    firebase-tools copied to clipboard
                            
                            
                            
                        Allow database import at runtime
[REQUIRED] Environment info
firebase-tools: 8.4.0
Platform: MacOS
[REQUIRED] Test case
n/a
[REQUIRED] Steps to reproduce
- start the emulator with --import to preload an already exported data set.
 - check on the new ui that the data is imported
 - clear the database using REST api described at https://firebase.google.com/docs/emulator-suite/connect_and_prototype#clear_your_database_between_tests
 - check on the ui, the data is gone
 
[REQUIRED] Expected behavior
The database is reset to its initial state with the imported data present
[REQUIRED] Actual behavior
The database is empty, the initial data is not restored.
@canatella that is currently working as intended although I can see how that can be confusing or frustrating as well.
It won't be technically feasible for us to import after every delete, but we can/should make it easier to import at runtime so that you can do multiple imports over the course of your testing. Would that help?
Sure! As long as there is a quick way to ensure that the database is in a known state between each tests. Thank you for being so reactive ;)
@canatella great, I have changed the title of the issue to reflect that. We're working on adding runtime import/export support to the Emulator UI and once we're done that we can probably figure out how to expose the same hooks to unit testing.
We're working on adding runtime import/export support
Just to know if i need to open a new issue or if this planned feature would cover my use case:
I need to populate the firestore emulator with data containing dates relative to the current date, so the static data saved / loaded by export / import feature do not work.
Currently i start the emulator and manually run a node script populating firestore with required data.
The feature you are working cover this use case?
E.g., it will be possible to define a node script (with runtime data manipulation) that is called when starting the firestore emulator?
@blikblum sorry but that is not something we are considering implementing, our focus is on static imports.
Just to capture my own thoughts here: what we need to make this happen is an import HTTP endpoint inside the Firestore emulator that we can call, just like we already have an export endpoint:
https://github.com/firebase/firebase-tools/blob/226ea560fb4dba574c87fcbceb11765f47931443/src/emulator/hubExport.ts#L88
@samtstern I was actually looking for that import endpoint in the firebase-tools 👍
@samtstern is there any news on this feature?
@samtstern Any news on the feature?
any news ? @samtstern @bkendall
Still hoping! ✌🏼
Not being able to import data while tests run is at this point a major deciding factor in using firebase or not. Hope this can get added soon.
Sorry to post a comment only to say that I would really very much love to have this, but I really would 😅 Still no update on this subject?