Buka konsol

Set up the Firebase Emulators

The Firebase Emulators make it easier to fully validate your app's behavior and verify your Firebase Security Rules configurations. Use the Firebase Emulators to run and automate unit tests in a local environment.

Install the Firebase Emulators

Before you start, make sure you're using the latest versions of Java and Node.js.

To install the Firebase Emulators, use the Firebase CLI and follow the steps below.

  1. Run the following command(s) to install each emulator:

    Cloud Firestore

    firebase setup:emulators:firestore
    

    Realtime Database

    firebase setup:emulators:database
    
  2. Start the emulator using the following command. The emulator runs during all your tests.

    Cloud Firestore

    firebase serve --only firestore
    

    Realtime Database

    firebase serve --only database
    

Set up tests and run the emulator

Now that you've installed the emulator, set up tests and generate reports to validate your rules' behavior before you deploy them to production.

Quickstart

For a few basic test cases with simple rules, try out the JavaScript quickstart or the TypeScript quickstart.