Open SamyPesse opened 4 years ago
@SamyPesse this is a reasonable feature request and should be feasible to implement. Can you explain the reason that you don't want to emulate all functions though? Curious if there's an underyling emulator improvement we could make.
I'm basically running a script generate-tests-data
to prepare the dataset for unit testing:
export CF_IS_PREPARING_DATASET="true"
firebase emulators:exec --only firestore,functions \
"yarn node write-to-emulator.ts && \
sleep 60 && \
curl http://localhost:8080/emulator/v1/projects/$PROJECT_ID:ruleCoverage.html > tests/coverages/firestore.html && \
firebase emulators:export ./dump/tests --force"
To explain this code:
functions
emulator because some documents are "computed" in cloud functionsCF_IS_PREPARING_DATASET
to have different exports and not run all functions, because only a few are used to compute those data, and most other functions depend on external servicessleep 60
to wait for the end of the CF executions 🙃curl
to access the coverage after executing the commandThe improvements I'd like from Firebase are:
firebase emulators:exec
to avoid the use of an env CF_IS_PREPARING_DATASET
to return a different set of functionsfirebase emulators:functions:wait
to wait for all cloud functions executions to be finished (similar to https://github.com/firebase/firebase-tools/issues/1813)@SamyPesse I just sent a PR to fix #1813 which will be included in the next release. We'll now wait up to 60s for any functions to finish when the emulators are stopped.
Thanks @samtstern, but we'll probably have to keep using the bash script with the sleep 60
because we want to run curl http://localhost:8080/emulator/v1/projects/$PROJECT_ID:ruleCoverage.html > tests/coverages/firestore.html
to download the rules coverage before the emulator is killed
@SamyPesse makes sense I actually end up in this situation a lot. Would it be useful for you if the emulator always wrote the rules coverage report to a file on exiting? Or do you prefer to have more control over when/where that happens?
@samtstern yes it'll fix it 👍
Right now there is no way to do only start the emulator with a subset of functions enabled instead of all. It requires a custom build or filter the exports ourself.
It'd be great if the
firebase emulators:exec
andfirebase emulators:start
would accept an argument like--functions a,b
or maybe the same syntax asfirebase deploy
:--only functions:a,functions:b
(this is what I was expecting at first)