Upstatement
Published in

Upstatement

Jest mocks roasting on an open Firestore

Photo by Alex Holt on Unsplash

What To Test

Fully Mocking Firebase

Nelson mocking firebase
Example of how to add a new user to a firestore collection
  1. Firebase is an object that has a firestore function
  2. firestore() returns an object with a collection function
  3. collection() returns an object that has an add function
  4. add() returns a promise
An example of mocking firebase for a specific example
An example of a long query in firestore
A simple version of a mocked Firestore class
Example of how to use our mockFirebase function

Only Test YOUR Code

A function where a query may or may not be called
Example of how to use our mockFirebase method with assertions on our fake database

We Open Sourced It!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store