
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
- 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"shell": "npm run build && firebase emulators:exec --import localdb/ --only firestore,auth \"npm run test\"", | |
"test": "firebase functions:shell --inspect-functions" | |
} | |
} |
Have a nice day, or night.