Migrate from the Local Emulator Suite
Fireemu reads your existing firebase.json, serves the same ports, and accepts the official command names, so most projects move by changing one command.
-
Install Fireemu and create
fireemu.tomlthat references yourfirebase.json:Terminal window npm install --save-dev fireemunpx fireemu init --firebase-json firebase.jsonKeep
profile = "strict", the default. -
Replace the commands:
Before After firebase emulators:exec "npm test"fireemu exec -- npm testfirebase emulators:startfireemu upfireemu emulators:execandfireemu emulators:startalso work, andexecaccepts the official quoted-script form. -
Run your tests.
When a test fails under strict
Section titled “When a test fails under strict”A test that passed on the official emulator but fails under strict usually shows behavior your application would also meet in production. Fix the test or the application, or relax only the specific setting below, rather than switching the whole profile to emulator.
- Unsigned emulator ID tokens.
@firebase/rules-unit-testing’sauthenticatedContext()and the client SDK’smockUserTokenwork understrictby default. Setauth.allowUnsignedIdTokenstofalseto test production’s refusal of them. - Named databases. Declare each named database in the
firestorearray offirebase.json, with itsrulesandindexesfiles, or create it through the Admin API, as production needs it created. A database created at run time has no Security Rules until you load some for it (see Firestore). - Composite indexes. Queries are checked against your declared indexes, as production checks them. Declare the index a query needs in
firestore.indexes.json, referenced fromfirebase.json. A query whose index is missing is refused withFAILED_PRECONDITIONand a link to the index, as in production. A composite index with a single field is refused when the file loads, asfirebase deployrefuses it: usefieldOverrides. To keep running such queries while you add the indexes, setfirestore.missingIndexesto"report": the query runs and the missing index is reported on standard error. - Settings that mirror your production project. Set them to match it instead of switching the profile:
| Setting | What it does under strict |
|---|---|
auth.improvedEmailPrivacy |
Email enumeration protection, on for a new production project. Set false only if your production project turned it off; sign-ins then answer EMAIL_NOT_FOUND and INVALID_PASSWORD as the official Auth emulator does. |
auth.mfa |
Your project’s multi-factor configuration. strict starts with SMS and TOTP enabled; productionExact starts with multi-factor off, as a new production project does. See Authentication. |
firestore.enforceLimits |
Production always enforces the Standard edition query limits. false lets queries pass that production refuses, so leave it on unless you have a specific reason. Under strict it switches only the query limits. |
Differences from the official CLI
Section titled “Differences from the official CLI”- A failed
--export-on-exitmakes the run exit 1 when the command succeeded. The official CLI only warns and exits 0; Fireemu differs so that a CI job that depends on the saved data cannot pass without it. - On Unix, a discovered
fireemu.tomlorfirebase.jsonis loaded only when its owner is trusted. See Configuration files. - Under
strict, a project without Security Rules behaves as a production project without a rules release: client requests are refused. See Security Rules.