Skip to main content

Posts

Showing posts from June, 2020

mock firebase for jest

https://stackoverflow.com/questions/52043886/how-do-you-mock-firebase-firestore-methods-using-jest 'use strict' const collection = jest . fn (() => { return { doc : jest . fn (() => { return { collection : collection , update : jest . fn (() => Promise . resolve ( true )), onSnapshot : jest . fn (() => Promise . resolve ( true )), get : jest . fn (() => Promise . resolve ( true )) } }), where : jest . fn (() => { return { get : jest . fn (() => Promise . resolve ( true )), onSnapshot : jest . fn (() => Promise . resolve ( true )), } }) } }); const Firestore = () => { return { collection } } Firestore . FieldValue = { serverTimestamp : jest . fn () } export default class RNFirebase { static initializeApp = jest . fn (); static auth = jest . fn (() => { return