|
| 1 | +# Integration Test Suite |
| 2 | + |
| 3 | +## How to use |
| 4 | + |
| 5 | +### Prerequisites |
| 6 | + |
| 7 | +Tests use locally installed firebase to invoke commands for deploying functions. |
| 8 | +The tests also require that you have gcloud CLI installed and authenticated |
| 9 | +(`gcloud auth login`). |
| 10 | + |
| 11 | +Tests are deployed with a unique identifier, which enables the teardown of its own resources, without affecting other test runs. |
| 12 | + |
| 13 | +1. Add a service account at root serviceAccount.json |
| 14 | +2. Add a .env `cp .env.example .env` |
| 15 | +3. Ensure service account has required roles for each cloud service |
| 16 | +4. Ensure any resources such as eventarc channel ("firebase" is used as default) are configured |
| 17 | + |
| 18 | +### Running setup and tests |
| 19 | + |
| 20 | +This will deploy functions with unique names, set up environment for running the jest files, and run the jest test suite. |
| 21 | + |
| 22 | +```bash |
| 23 | +yarn start |
| 24 | +``` |
| 25 | + |
| 26 | +## TODO |
| 27 | + |
| 28 | +[x] Deploy functions with unique name |
| 29 | +[x] Update existing tests to use jest (v1 and v2) |
| 30 | +[x] Add missing coverage for v1 and v2 (WIP) |
| 31 | +[x] Ensure proper teardown of resources (only those for current test run) |
| 32 | +[] Analytics: since you cannot directly trigger onLog events from Firebase Analytics in a CI environment, the primary strategy is to isolate and test the logic within the Cloud Functions by mocking Firebase services and the Analytics event data. This is done elsewhere via unit tests, so no additional coverage added. |
| 33 | +[] Alerts: same as analytics, couldn't find way to trigger. |
| 34 | +[] Auth blocking functions can only be deployed one at a time, half-way solution is to deploy v1 functions, run v1 tests, teardown, and repeat for v2. However, this still won't allow for multiple runs to happen in parallel. Solution needed before re-enabling auth/identity tests. You can run the suite with either v1 or v2 commented out to check test runs. |
| 35 | +[] Https tests were commented out previously, comments remain as before |
| 36 | +[] Python runtime support |
| 37 | + |
| 38 | +## Troubleshooting |
| 39 | + |
| 40 | +- Sometimes I ran into this reported [issue](https://github.com/firebase/firebase-tools/issues/793), I had to give it some period of time and attempt deploy again. Probably an upstream issue but may affect our approach here. Seems to struggle with deploying the large amount of trigger functions...? Falls over on Firebase Storage functions (if you comment these out everything else deploys as expected). |
0 commit comments