Firebase Emulators - swent-group4/sudden-bump GitHub Wiki
Research on Firebase Emulators
by Deyan Marinov
Introduction
Firebase Emulators are a set of emulators provided by the Firebase CLI Tools (installation docs / emulator docs). These tools provide many more useful assets on top of the Emulators. It is worth checking out the full documentation to learn more about them.
Installation
Prerequisites
You need to have the following packages installed on your machine:
- Node.js version 16.0 or higher
- Java JDK version 11.0 or higher
Please search Google or ask ChatGPT to find how to install this on your machine (package managers recommended!).
Windows
You'll find their binary here. Open a Command Prompt in the directory where you downloaded the binary and run firebase [command]
.
Linux/macOS
Run the following line in bash:
curl -sL https://firebase.tools | bash
.
This will automagically detect your OS, download and enable the firebase
command globally.
Setup
For this tutorial to work, please make sure you are running all of these commands from your sudden-bump
directory.
- Once installed, run
firebase login
. This will open a browser page for you to login with your Google Account used for our project (doesn't work in a headless environment). - Once logged in, run
firebase init emulators
to begin the setup of the emulators. Follow the on-screen instructions and select thesudden-bump
project. - Select the desired emulators. The most important one is the Firestore emulator, but maybe you'll need something else, so read the list carefully and make your choice accordingly.
- Pick the ports you want to use for the different emulators. I'd recommend leaving the default values if there's not specific reason for you to change them. Reply "Y" to the question asking if you want to download the emulators.
Starting and using the Emulators
In your sudden-bump
project folder, run firebase start:emulators
in the Terminal. This will start the emulators on the different ports you selected during setup. You also have the GUI available on localhost:4000 (by default).
If you go in the GUI, you'll notice that it resembles quite a lot the Firebase in the Cloud, except that it is running on your own machine, so you can essentially have the data you want. In order to connect your tests to the emulator and understand how to use the emulator, please follow the explanations and tutorials on the docs.
Using with the CI
TBD - see https://firebase.google.com/docs/emulator-suite/install_and_configure#integrate_with_your_ci_system