Developer blog | Ondřej Polách

Firebase shell with emulators and debugging
26.05.2021 firebase

Testing firebase callable functions can be problematic. There is guide how simply set environment for support debugging of callable functions and using Firestore emulator, instead of production version.

Content

  1. Change package.json

Change package.json

Firebase CLI has option for exec script after emulators started - emulators:exec. You can select which emulators start using --only flag. You can import local db using --import flag.
Then run npm script which using firebase cli for run cloud functions's shell. For debugging add flag --inspect-functions.
That's all. Now you can attach debugger and test your functions (not only callable) interactively.

{
"scripts": {
"shell": "npm run build && firebase emulators:exec --import localdb/ --only firestore,auth \"npm run test\"",
"test": "firebase functions:shell --inspect-functions"
}
}
view rawpackage.jsonhosted with ❤ by GitHub

Have a nice day, or night.