Skip to content

Commit b5a3653

Browse files
committed
added enhancements about cloud functions testing into readme file
1 parent b2683f8 commit b5a3653

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Boilerplate with React ⚛️ and Firebase 🔥designed to quickly spin up a ful
2323
- [Unit Testing](#unit-testing)
2424
- [Linting](#linting)
2525
- [Cloud functions](#cloud-functions)
26+
- [Unit Testing](#unit-testing-1)
2627
- [Prerequisites](#prerequisites)
2728
- [Getting started](#getting-started)
2829
- [Setting up the Firebase project locally](#setting-up-the-firebase-project-locally)
@@ -42,7 +43,7 @@ Boilerplate with React ⚛️ and Firebase 🔥designed to quickly spin up a ful
4243
- [Selecting an alias](#selecting-an-alias)
4344
- [Creating a new cloud function](#creating-a-new-cloud-function)
4445
- [Testing functions locally](#testing-functions-locally)
45-
- [Testing functions in online mode](#testing-functions-online)
46+
- [Testing functions in online mode](#testing-functions-in-online-mode)
4647
- [Deployment](#deployment)
4748
- [Continuous integration/deployment](#continuous-integrationdeployment)
4849
- [Workflows folder structure](#workflows-folder-structure)
@@ -59,7 +60,7 @@ Boilerplate with React ⚛️ and Firebase 🔥designed to quickly spin up a ful
5960
- [How to internationalize a Date](#how-to-internationalize-a-date)
6061
- [How to add your language on DatePicker](#how-to-add-your-language-on-datepicker)
6162
- [File Upload](#file-upload)
62-
- [Image Resize](#image-resize)
63+
- [Image resize extension](#image-resize-extension)
6364
- [Storage Rules](#storage-rules)
6465
- [Contributors](#contributors)
6566
- [License](#license)
@@ -146,9 +147,13 @@ React Firebase Admin is our in-house admin dashboard boilerplate, used in many o
146147
- [Camelcase](https://github.com/sindresorhus/camelcase) (★ 423) convert a dash/dot/underscore/space separated string to camelCase.
147148
- [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.
148149

149-
### Unit Testing
150+
#### Unit Testing
150151

151152
- [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.
152157

153158
## Prerequisites
154159

@@ -332,8 +337,20 @@ functions/
332337
│ │ ... storage functions ...
333338
│ ├── https/
334339
│ │ ├── createUser.function.ts
335-
│ │ └── ... other https functions ...
340+
│ │ └── ... other https functions ...
336341
│ └── 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+
337354
```
338355

339356
### Installing dependencies
@@ -415,9 +432,15 @@ Testing your cloud functions online is very simple and easy.
415432
416433
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)
417434
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.
419442
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**.
421444
422445
_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._
423446

0 commit comments

Comments
 (0)