Migrate from the Local Emulator Suite
If you decide to try Fireemu, it reads your existing firebase.json, serves the same default ports, and accepts the official command names, so most projects move by changing one command. Before you switch, check that the products you use are on the supported list: the Local Emulator Suite also serves App Hosting, Data Connect and Extensions, which Fireemu does not, and Hosting and the Realtime Database are partial.
-
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 often 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 disable their fallback on the Security Rules surfaces and test production’s refusal of them. For a refusal test, use the SDK helper’s defaultiat: 0/exp: 3600with a clock after expiry; fireemu-issued tokens that pass normal verification are still accepted. Useauth.idTokenSigning = "session-rsa"to refuse all unsigned ID tokens. See Unsigned mock ID tokens. - 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 with
FAILED_PRECONDITIONand a link to the index, as in production. - A composite index with a single field is refused when the file loads, as
firebase deployrefuses it: usefieldOverrides. - To keep running such queries while you add the indexes, set
firestore.missingIndexesto"report": the query runs and each missing index is reported once per database on standard error, with production’s refusal text and thefirestore.indexes.jsonentry.productionExactdoes not change this key. - For OR queries, supplementary standard-error diagnostics list all distinct missing branch indexes, so you can add their definitions together;
strictstill returns the existing SDK error with the first index creation link, and theemulatorprofile still serves the query. Repeated suggestions are deduplicated and the diagnostic cache is bounded.
- A query whose index is missing is refused with
- 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.