This app connects to several Firebase (BaaS) services in production. This cloud service should not be used during development. With the Firebase Javascript SDK and the Firebase Emulator Suite, we can run everything locally.
With the emulator set up for local development, there is only one more step: using the Firebase Emulator in the GitHub Actions during testing.
// create testenv for mocking changes
const testEnv = functions();
// First set up unique project id for these tests, so that any other test files run in parallel
// is not collapsing with this one.
const projectId = 'sample';
// initialize test database
process.env.GCLOUD_PROJECT = projectId;
process.env.FIRESTORE_EMULATOR_HOST = 'localhost:8080';
admin.initializeApp({ projectId });
const db = admin.firestore();
use Firebase Emulator
This app connects to several Firebase (BaaS) services in production. This cloud service should not be used during development. With the Firebase Javascript SDK and the Firebase Emulator Suite, we can run everything locally.
With the emulator set up for local development, there is only one more step: using the Firebase Emulator in the GitHub Actions during testing.
Checklist
Research
package.json
GitHub Actions example
Cache the Firebase emulator
NodeJS Firestore mock
firebase.json