Example repo for the Why mocking sucks post illustrating testing Firebase services with mocking vs with the Firebase emulator.
Create a Firebase project and download your service account key file from your project configuration. Paste the contents of the service account key into the service_account_key_example.json
file.
Use the following command to run mocked tests
uv run pytest firebase_test_with_mocking.py
Install the Firebase CLI.
npm install -g firebase-tools
Authenticate the CLI
firebase login
Initialize the project.
firebase init
Initialize Firebase Emulators.
firebase init emulators
Start the emulator.
firebase emulators:start
Run the test against the emulator
uv run pytest firebase_test_with_emulator.py