You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -145,9 +147,13 @@ React Firebase Admin is our in-house admin dashboard boilerplate, used in many o
145
147
-[Camelcase](https://github.com/sindresorhus/camelcase) (★ 423) convert a dash/dot/underscore/space separated string to camelCase.
146
148
-[Resize Image](https://github.com/firebase/extensions/tree/master/storage-resize-images) (★ 372) Firebase Extension to create resized versions of images uploaded to Cloud Storage.
147
149
148
-
### Unit Testing
150
+
####Unit Testing
149
151
150
152
-[Firebase-functions-test](https://github.com/firebase/firebase-functions-test) (★ 117) unit testing library for Cloud Functions for Firebase.
153
+
-[Mocha](https://github.com/mochajs/mocha) (★ 19.4k) simple, flexible, fun javascript test framework for node.js & the browser.
154
+
-[Chai](https://github.com/chaijs/chai) (★ 6.8k) BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
155
+
-[Chai-as-promised](https://github.com/domenic/chai-as-promised/) (★ 1.4k) Extends Chai with assertions about promises.
156
+
-[Ts-node](https://github.com/TypeStrong/ts-node) (★ 7k) TypeScript execution and REPL for node.js, with source map support.
151
157
152
158
## Prerequisites
153
159
@@ -324,15 +330,27 @@ functions/
324
330
| │ └── onDelete.function.ts
325
331
│ ├── db/
326
332
│ │ ├── users/
327
-
│ │ ├── onCreate.function.ts
328
-
│ │ ├── onModify.function.ts
329
-
│ │ └── ... other database functions ...
333
+
│ │ │ ├── onCreate.function.ts
334
+
│ │ │ ├── onModify.function.ts
335
+
│ │ │ └── ... other database functions ...
330
336
│ ├── storage/
331
337
│ │ ... storage functions ...
332
338
│ ├── https/
333
339
│ │ ├── createUser.function.ts
334
-
│ │ └── ... other https functions ...
340
+
│ │ └── ... other https functions ...
335
341
│ └── index.ts
342
+
├── test/
343
+
│ ├── db/
344
+
│ │ ├── users/
345
+
│ │ │ ├── onDelete.test.ts
346
+
│ │ │ ├── onUpdate.test.ts
347
+
│ │ │ └── ... other database tests ...
348
+
│ ├── https/
349
+
│ │ ├── createUser.test.ts
350
+
│ │ └── ... other https tests ...
351
+
│ └── util/
352
+
│ ├── config.ts
353
+
│
336
354
```
337
355
338
356
### Installing dependencies
@@ -408,6 +426,24 @@ After it initializes, you should get your endpoints to test your HTTP functions:
408
426
409
427
More information about the [Firebase Emulator](https://firebase.google.com/docs/rules/emulator-setup).
410
428
429
+
### Testing functions in online mode
430
+
431
+
Testing your cloud functions online is very simple and easy.
432
+
433
+
For that, you only have to set the variables localted in the env.example.json inside /functions folder. (Remember to rename the file to env.json)
434
+
435
+
Follow these steps for setting up your env.json file:
436
+
437
+
- The first 3 properties **_"databaseURL"_**, **_"storageBucket"_** and **_"projectId"_** are the same ones previously added to the frontend .env file.
438
+
- For **_"serviceAccountKey"_** you should do the following:
439
+
- Go to your proyect in the Firebase dashboard, click on **_Project settings_** and then click on **_Service accounts_** tab.
440
+
- After that you'll be able to click on **_Generate new private key_** button and a json file containing your service account's credentials will be downloaded.
441
+
- Place that file in your project and include the location of it into the **_"serviceAccountKey"_** in your env.json file.
442
+
443
+
After that, open your terminal, navigate to the /functions folder and execute **npm test**.
444
+
445
+
_Warning: Use extra caution when handling service account credentials in your code. Do not commit them to a public repository, deploy them in a client app, or expose them in any way that could compromise the security of your Firebase project._
446
+
411
447
### Deployment
412
448
413
449
When a pull request gets merged into development, functions are deployed automatically to the staging project in Firebase. Likewise, when merging/pushing into master, they're deployed to production.
@@ -634,6 +670,7 @@ We'd like to thank these awesome people who made this whole thing happen:
0 commit comments