Moves unit tests from using the production database to an emulator.
This PR sets up the framework for unit tests to test various firebase functions as well as use emulators for internal testing.
A big feature that this implements is the ability for the app to be able to connect to an emulator. This means that once the app is live, we will no longer have the need to use the production database for
To use the emulator, various environment variables must be set in .env. These define various places where the app/testing environment will connect. The only lines that need to be added are the emulators that are being connected to. For example, you can use the production auth service (recommended) while still using the firestore emulator service:
FIREBASE_EMULATOR_ADDRESS = 127.0.0.1 # Change this to a real host address
FIREBASE_AUTH_PORT = 9099 # Recommended to omit this line if using the app.
FIREBASE_FIRESTORE_PORT = 8080
FIREBASE_CLOUD_FUNCTIONS_PORT = 5001
FIREBASE_STORAGE_PORT = 9199
Note: campus wifi does not allow hosting, so in order to use the emulator on campus, the user must come up with a method to connect to the emulator via LAN or other methods.
The testing framework also mocks firebase/auth as the current implementation contains require cycles which mess with jest. Hopefully this changes in the future, but for now auth does not have full functionality in testing.
Moves unit tests from using the production database to an emulator.
This PR sets up the framework for unit tests to test various firebase functions as well as use emulators for internal testing.
A big feature that this implements is the ability for the app to be able to connect to an emulator. This means that once the app is live, we will no longer have the need to use the production database for
To use the emulator, various environment variables must be set in
.env
. These define various places where the app/testing environment will connect. The only lines that need to be added are the emulators that are being connected to. For example, you can use the production auth service (recommended) while still using the firestore emulator service:Note: campus wifi does not allow hosting, so in order to use the emulator on campus, the user must come up with a method to connect to the emulator via LAN or other methods.
The testing framework also mocks
firebase/auth
as the current implementation contains require cycles which mess with jest. Hopefully this changes in the future, but for now auth does not have full functionality in testing.