Skip to content

Testing

Jacob Smith edited this page Jan 12, 2021 · 2 revisions

Before you can start testing the functions, you'll need to create a test Firebase project using the Firebase Setup instructions. This test project will be used within the test suite to avoid messing the production data. Follow these instructions to create a service account and save the file as serviceAccountKey.relar-test.json in the root of the repository.

Eventually, once there is a storage emulator (see this issue), we won't need a test project.

Next, you will need to create a local .runtimeconfig.json file with the firebase functions config. This .runtimeconfig.json file is loaded during testing automatically (more information here) since function config is not loaded.

# in functions/
firebase functions:config:get --project <PROJECT_ID> > .runtimeconfig.json

Make sure to use the project ID from your real firebase project and not your test project.

Both the app and functions directories have their own test suite that uses esbuild-register and uvu to run the tests. In either of the directories, you can now run the test command to kick off the test suite.

# in functions/ or app/
npm run test
Clone this wiki locally