Introduction

Before you begin

The Firebase Local Emulator Suite is a set of advanced tools for developers looking to build and test apps locally using Cloud Firestore, Realtime Database, Cloud Functions, Cloud Pub/Sub and Firebase Hosting. Local development with Local Emulator Suite can be a good fit for your prototyping, development and continuous integration workflows.

Before you explore Firebase Local Emulator Suite, we recommend you get oriented to Firebase products and the Firebase development model:

  • Read the Get started with Firebase topics for your platform and products (iOS, Android or Web).
  • Download a ready-to-run quickstart app on your platform of choice, then read through and execute the code. The FriendlyEats quickstart app is a good choice (iOS, Android or Web).

What is Firebase Local Emulator Suite?

The Firebase Local Emulator Suite consists of individual service emulators built to accurately mimic the behavior of Firebase services. This means you can connect your app directly to these emulators to perform integration testing or QA without touching production data.

For example, you could connect your app to the Firestore emulator to safely read and write documents in testing. These writes may trigger functions in the Cloud Functions emulator. However your app will still continue to communicate with production Firebase services when emulators are not available or configured.

Emulator Suite in your local workflows

Your prototype and test workflow can make use of the Local Emulator Suite in three ways:

  • Unit Tests: using the Firebase Test SDK, you can write unit tests in Node.js using the mocha test runner. The Test SDK provides several convenience methods for loading Security Rules, flushing the local database between tests, and managing synchronous interaction with the emulators. It's great for writing simple tests for database interactions that don't depend on your app's logic.
  • Integration Tests: each individual product emulator in the Emulator Suite responds to SDK and REST API calls just like production Firebase services. So you can use your own testing tools to write self-contained integration tests that use the Emulator Suite as the backend.
  • Manual Tests: you can connect your running application to the Emulator Suite to test your Firebase app manually, without risking production data or configuring a test project.

Which Firebase features and platforms are supported?

The Firebase Local Emulator Suite allows you to test your code with our core products in an interoperable way. The Cloud Functions emulator supports HTTP functions, callable functions, and background functions triggered by Cloud Firestore, Realtime Database and Cloud Pub/Sub; the Cloud Functions emulator does not support background functions triggered by Auth or Cloud Storage for Firebase. For Cloud Firestore and Realtime Database emulators, Security Rules emulation is built in.

Cloud
Firestore
Realtime
Database
Cloud
Functions
Cloud
Pub/Sub
Android SDK n/a
iOS SDK n/a
Web SDK n/a
Node.js Admin SDK n/a

Other tools for prototyping and testing

The Emulator Suite is supplemented by other prototype and test tools.

Cloud Functions testing tools. The Firebase CLI environment provides you several ways to prototype and test functions:

  • The Cloud Functions emulator, part of the Emulator Suite. This emulator is interoperable with local, live data and Security Rules in the Firestore emulator and/or Realtime Database emulator.
  • The Cloud Functions shell, which allows for interactive, iterative functions prototyping and development. The shell employs the Cloud Functions emulator with a REPL-style interface for development. No integration with the Firestore or Realtime Database emulators is provided. Using the shell, you mock data and perform function calls to simulate interaction with products that the Emulator Suite does not currently support: Storage, PubSub, Analytics, Remote Config, Storage, Auth, and Crashlytics.
  • The Firebase Test SDK for Cloud Functions, a Node.js with mocha framework for functions development. In effect, the Cloud Functions Test SDK provides automation atop the Cloud Functions shell.

You can find more about the Cloud Functions shell and Cloud Functions Test SDK at Test functions interactively and Unit testing of Cloud Functions.

Security Rules testing tools. Emulator Suite is the preferred toolset for testing Security Rules. However, you can also use:

  • The Rules Simulator, a part of the Firebase console. The Simulator provides a great interactive getting started experience with Security Rules design. For more information see Quickly validate Firebase Security Rules.