Template for having split up cloud functions (triggers/endpoints) with included jest
testing.
Requires firebase-tools:
$ npm i -g firebase-tools
Install all dependencies (node version should match package.json engines):
$ cd functions
$ nvm use # will read .nvmrc (default: v8)
$ yarn
Add your firebase project
$ firebase use --add
Add your service-account.json
to the functions
folder:
{
+ "type": "service_account",
+ "project_id": "",
+ "private_key_id": "",
+ "private_key": "",
+ "client_email": "",
+ "client_id": "",
+ "auth_uri": "",
+ "token_uri": "",
+ "auth_provider_x509_cert_url": "",
+ "client_x509_cert_url": "",
}
Fill in your API details in config/*.json
Development: firebase serve
with hot-reloading
$ yarn dev
Testing: jest
$ yarn test
Currently in beta. If you want to try it out you will need to enable it in your package.json
"engines": {
- "node": "8"
+ "node": "10"
},
Also modify your .nvmrc
if you use nvm / fnm / fish-nvm
- v8
+ v10
- Develop Apps Script using TypeScript
- Firebase CLI Reference
- Unit testing of Cloud Functions
- How to Test Firebase Cloud Functions With Jest
MIT