All Projects → akauppi → firebase-jest-testing

akauppi / firebase-jest-testing

Licence: MIT license
Firebase back-end testing, using Jest.

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to firebase-jest-testing

barber-shop
Vue + Firebase (cloud functions, auth, firestore, hosting) reservations system
Stars: ✭ 47 (+123.81%)
Mutual labels:  cloud-functions, firestore
fireschema
Strongly typed Firestore framework for TypeScript
Stars: ✭ 193 (+819.05%)
Mutual labels:  cloud-functions, firestore
serverless-rest-api
Building RESTful Web APIs with Firebase Cloud Function, Firestore, Express and TypeScript
Stars: ✭ 103 (+390.48%)
Mutual labels:  cloud-functions, firestore
app
Source code of intencje.pl website and mobile/desktop apps based on Angular, Firebase, and Capacitor.
Stars: ✭ 12 (-42.86%)
Mutual labels:  cloud-functions, firestore
universal-translator
Demo app using Firebase and Google Cloud products to implement a "universal translator"
Stars: ✭ 37 (+76.19%)
Mutual labels:  cloud-functions, firestore
rowy
Open-source Airtable-like experience for your database (Firestore) with GCP's scalability. Build any automation or cloud functions for your product. ⚡️✨
Stars: ✭ 2,676 (+12642.86%)
Mutual labels:  cloud-functions, firestore
foundry-cli
Foundry makes the development of Firebase Functions fast by giving you an out-of-the-box working cloud environment for your development with an access to your production data. It's a CLI tool that gives you a continuous REPL-like feedback about your Firebase Functions.
Stars: ✭ 49 (+133.33%)
Mutual labels:  cloud-functions, firestore
react-firebase-context
A basic set of components that help dealing with Firebase services
Stars: ✭ 41 (+95.24%)
Mutual labels:  firestore
pring-admin.ts
Cloud Firestore model framework for TypeScript - Google
Stars: ✭ 13 (-38.1%)
Mutual labels:  firestore
vue-js-3-firebase-firestore
Vue 3 Firebase Tutorial: Build Firestore CRUD Web Application
Stars: ✭ 34 (+61.9%)
Mutual labels:  firestore
nand nor
C++ Compile time NAND/NOR obfuscation
Stars: ✭ 32 (+52.38%)
Mutual labels:  emulation
retropie-overlays
Console overlays set for Retropie & Recalbox
Stars: ✭ 54 (+157.14%)
Mutual labels:  emulation
firestore-storage
A typed wrapper around Firestore incluing a querybuilder and an in-memory implementation for testing
Stars: ✭ 27 (+28.57%)
Mutual labels:  firestore
demo-firebase-js
A simple Web application that demonstrates how the end-to-end encryption works. The application uses firebase as a backend service for authentication and chat messaging, and Virgil E3Kit SDK for end-to-end encryption.
Stars: ✭ 31 (+47.62%)
Mutual labels:  firestore
SampleFoodBlog
🔥 Android blog application, built with Firebase
Stars: ✭ 23 (+9.52%)
Mutual labels:  firestore
FirmWire
FirmWire is a full-system baseband firmware emulation platform for fuzzing, debugging, and root-cause analysis of smartphone baseband firmwares
Stars: ✭ 555 (+2542.86%)
Mutual labels:  emulation
8080
A complete emulation of the Intel 8080 processor written in C99.
Stars: ✭ 109 (+419.05%)
Mutual labels:  emulation
LemonLime
A Nintendo 3DS LLE emulator written in C#
Stars: ✭ 57 (+171.43%)
Mutual labels:  emulation
Pi1541-HAT
A HAT for the Raspberry Pi, that allows to emulate the Commodore C64 floppy disk drive 1541. Switches and IEC-Bus detachable.
Stars: ✭ 26 (+23.81%)
Mutual labels:  emulation
pinmame
PinMAME - Pinball Multiple Arcade Machine Emulator
Stars: ✭ 77 (+266.67%)
Mutual labels:  emulation

firebase-jest-testing

This README is for the developers.

For using the package, see package/README.md (that ships with the package).


Tools for testing Firebase back-end features, using Jest.

This repo provides a "one stop", opinionated approach to testing Firebase projects. Using it may save you from reading countless pages of documentation and evaluating different testing strategies and libraries.

Also, the tools handle configuring emulation for you. In all, this tries to give a simpler development experience than the current (Aug 2021) Firebase tooling does.

The idea is that you don't have to pull in either firebase-admin nor firebase in your own testing project, but get all the tools through here.

Folder structure

The package itself is placed under package.

The sample folder contains a sample Firebase backend used for testing:

  • sample/functions has the definitions of the Cloud Functions
  • sample/firestore.rules has the Firestore Security Rules
  • sample/test-fns contains Cloud Function tests
  • sample/test-rules contains Security Rules tests

You can use this sample as a template for your own Firebase backend testing project.

Requirements

  • node >= 16.5
  • npm >= 7.7.0

Getting started

Fetch dependencies:

$ npm install

Now, you're ready to start the emulation and run tests against it.

Two ways ahead

There are two ways to run the tests, each with their own pros and cons. We'll call them the "CI" (Continuous Integration) and "dev" (development) flows, according to their main use cases.

Let's start with the simpler one.

CI: Run all the tests

Launching the tests is this easy:

$ cd sample
$ npm install
...
$ npm test
...
Test Suites: 2 passed, 2 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        2.547 s, estimated 3 s

...
Test Suites: 5 passed, 5 total
Tests:       29 passed, 29 total
Snapshots:   0 total
Time:        5.389 s

There are two separate Jest test suites run here, one after the other. One for Cloud Functions and another for Security Rules tests. It is possible to merge these but the author currently thinks it's best to keep them separate.

In "CI mode", each run launches the emulators anew. This takes ~5s that we can spare, by using the "dev" mode.

Dev mode

In dev mode, a server runs continuously on the background so repeated runs of the tests are a bit faster. This same server can be used for both Cloud Functions and Security Rules testing - even in parallel.

$ cd sample  # unless you already are there

Starting the emulator

Start the emulator in one terminal, and leave it running:

$ npm run start

Once we run tests, it's worth checking the emulator output, occasionally.

Running tests

In another terminal:

$ npm run test:fns:greet
$ npm run test:fns:userInfo
...

For testing Security Rules:

$ npm run test:rules:invites
$ npm run test:rules:projects
$ npm run test:rules:symbols
$ npm run test:rules:userInfo
$ npm run test:rules:visited

Sure you get the gist of it. 🤓

These are prepared for you in package.json. When developing something, it's meaningful to run only one suite, at a time.

Once you think things are rolling fine, run npm test to confirm.

Note: Since both CI and dev use the same emulator ports (defined in firebase.json), one cannot launch npm test while the emulator is running. Shut it down by Ctrl-C.

Using Docker Compose 🎁

This is a more advanced (complex) setup, but one you should study for your own projects. It has some advantages:

  • no need for multiple terminals. Docker Compose keeps the emulators running and their console output can be observed in the Docker Desktop application.
  • no need for installing concurrently or firebase-tools npm modules.

See sample.dc/README for details.

CI setup

Continuous Integration uses Docker Compose, to run the same tests.

See ci/README for details.

Other docs

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].