Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Emulator #378

Merged
merged 30 commits into from
Jun 16, 2024
Merged

Firebase Emulator #378

merged 30 commits into from
Jun 16, 2024

Conversation

LucientZ
Copy link
Collaborator

@LucientZ LucientZ commented Jun 15, 2024

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.

@LucientZ
Copy link
Collaborator Author

LucientZ commented Jun 15, 2024

LOL THE CI TEST FAILED.

That's funny. Probably some setup failure.

edit: nvm it was me from a year ago being stupid. I made a unit test with randomness and didn't account for Murphy's Law

Copy link
Member

@JasonIsAzn JasonIsAzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. We could look into the rules issue later but not a high priority right now.

@JasonIsAzn JasonIsAzn merged commit 65effaa into dev Jun 16, 2024
1 check passed
@JasonIsAzn JasonIsAzn deleted the firebase-emulator branch June 16, 2024 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants