Skip to content

Commit bd6a491

Browse files
authored
Merge branch 'master' into feature/facebook-google-microsoft-auth
2 parents fff25b1 + d6ea06d commit bd6a491

File tree

13 files changed

+947
-20
lines changed

13 files changed

+947
-20
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@
4949
"paths": ["src"]
5050
}
5151
}
52+
},
53+
"env": {
54+
"mocha": true
5255
}
5356
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,6 @@ yarn-debug.log*
8484
yarn-error.log*
8585

8686
.firebase
87+
88+
# service account key
89+
serviceAccountKey.json

README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Boilerplate with React ⚛️ and Firebase 🔥designed to quickly spin up a ful
2424
- [Unit Testing](#unit-testing)
2525
- [Linting](#linting)
2626
- [Cloud functions](#cloud-functions)
27+
- [Unit Testing](#unit-testing-1)
2728
- [Prerequisites](#prerequisites)
2829
- [Getting started](#getting-started)
2930
- [Setting up the Firebase project locally](#setting-up-the-firebase-project-locally)
@@ -43,6 +44,7 @@ Boilerplate with React ⚛️ and Firebase 🔥designed to quickly spin up a ful
4344
- [Selecting an alias](#selecting-an-alias)
4445
- [Creating a new cloud function](#creating-a-new-cloud-function)
4546
- [Testing functions locally](#testing-functions-locally)
47+
- [Testing functions in online mode](#testing-functions-in-online-mode)
4648
- [Deployment](#deployment)
4749
- [Continuous integration/deployment](#continuous-integrationdeployment)
4850
- [Workflows folder structure](#workflows-folder-structure)
@@ -157,6 +159,14 @@ React Firebase Admin is our in-house admin dashboard boilerplate, used in many o
157159
- [Camelcase](https://github.com/sindresorhus/camelcase) (★ 423) convert a dash/dot/underscore/space separated string to camelCase.
158160
- [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.
159161

162+
#### Unit Testing
163+
164+
- [Firebase-functions-test](https://github.com/firebase/firebase-functions-test) (★ 117) unit testing library for Cloud Functions for Firebase.
165+
- [Mocha](https://github.com/mochajs/mocha) (★ 19.4k) simple, flexible, fun javascript test framework for node.js & the browser.
166+
- [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.
167+
- [Chai-as-promised](https://github.com/domenic/chai-as-promised/) (★ 1.4k) Extends Chai with assertions about promises.
168+
- [Ts-node](https://github.com/TypeStrong/ts-node) (★ 7k) TypeScript execution and REPL for node.js, with source map support.
169+
160170
## Prerequisites
161171

162172
- [Firebase](https://firebase.google.com/) account in order to set up the serverless BaaS for the project.
@@ -332,15 +342,27 @@ functions/
332342
| │ └── onDelete.function.ts
333343
│ ├── db/
334344
│ │ ├── users/
335-
│ │ ├── onCreate.function.ts
336-
│ │ ├── onModify.function.ts
337-
│ │ └── ... other database functions ...
345+
│ │ ├── onCreate.function.ts
346+
│ │ ├── onModify.function.ts
347+
│ │ └── ... other database functions ...
338348
│ ├── storage/
339349
│ │ ... storage functions ...
340350
│ ├── https/
341351
│ │ ├── createUser.function.ts
342-
│ │ └── ... other https functions ...
352+
│ │ └── ... other https functions ...
343353
│ └── index.ts
354+
├── test/
355+
│ ├── db/
356+
│ │ ├── users/
357+
│ │ │ ├── onDelete.test.ts
358+
│ │ │ ├── onUpdate.test.ts
359+
│ │ │ └── ... other database tests ...
360+
│ ├── https/
361+
│ │ ├── createUser.test.ts
362+
│ │ └── ... other https tests ...
363+
│ └── util/
364+
│ ├── config.ts
365+
344366
```
345367

346368
### Installing dependencies
@@ -416,6 +438,24 @@ After it initializes, you should get your endpoints to test your HTTP functions:
416438
417439
More information about the [Firebase Emulator](https://firebase.google.com/docs/rules/emulator-setup).
418440
441+
### Testing functions in online mode
442+
443+
Testing your cloud functions online is very simple and easy.
444+
445+
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)
446+
447+
Follow these steps for setting up your env.json file:
448+
449+
- The first 3 properties **_"databaseURL"_**, **_"storageBucket"_** and **_"projectId"_** are the same ones previously added to the frontend .env file.
450+
- For **_"serviceAccountKey"_** you should do the following:
451+
- Go to your proyect in the Firebase dashboard, click on **_Project settings_** and then click on **_Service accounts_** tab.
452+
- 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.
453+
- Place that file in your project and include the location of it into the **_"serviceAccountKey"_** in your env.json file.
454+
455+
After that, open your terminal, navigate to the /functions folder and execute **npm test**.
456+
457+
_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._
458+
419459
### Deployment
420460
421461
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.
@@ -742,6 +782,7 @@ We'd like to thank these awesome people who made this whole thing happen:
742782
<li><a href="https://github.com/jbheber">Juan Heber</a></li>
743783
<li><a href="https://github.com/vikdiesel">Viktor Kuzhelny</a></li>
744784
<li><a href="https://github.com/TOPOFGR">Franco Galeano</a></li>
785+
<li><a href="https://github.com/jfocco">Juan Focco</a></li>
745786
</ul>
746787
747788
## License

functions/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ typings/
77

88
node_modules/
99

10-
lib/
10+
lib/
11+
12+
#Necessary config for testing
13+
env.json

functions/env.example.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"databaseURL": "",
3+
"storageBucket": "",
4+
"projectId": "",
5+
"serviceAccountKey": ""
6+
}

0 commit comments

Comments
 (0)