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
@@ -146,9 +147,13 @@ React Firebase Admin is our in-house admin dashboard boilerplate, used in many o
146
147
-[Camelcase](https://github.com/sindresorhus/camelcase) (★ 423) convert a dash/dot/underscore/space separated string to camelCase.
147
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.
148
149
149
-
### Unit Testing
150
+
####Unit Testing
150
151
151
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.
152
157
153
158
## Prerequisites
154
159
@@ -332,8 +337,20 @@ functions/
332
337
│ │ ... storage functions ...
333
338
│ ├── https/
334
339
│ │ ├── createUser.function.ts
335
-
│ │ └── ... other https functions ...
340
+
│ │ └── ... other https functions ...
336
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
+
│
337
354
```
338
355
339
356
### Installing dependencies
@@ -415,9 +432,15 @@ Testing your cloud functions online is very simple and easy.
415
432
416
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)
417
434
418
-
After that, navigate to the /functions folder and execute **npm test** in your terminal.
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.
419
442
420
-
Note: For finding your service account key you should go to your proyect in the Firebase dashboard, click on **_Project settings_** and then click on **_Service accounts_** tab. 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. Place that file in your project and include the location of it into the **_"serviceAccountKey"_** in your env.json file.
443
+
After that, open your terminal, navigate to the /functions folder and execute **npm test**.
421
444
422
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._
0 commit comments