Created
October 15, 2019 22:28
-
-
Save danahartweg/1b25e0bf34d905914934f4948f9f2f86 to your computer and use it in GitHub Desktop.
Function admin helper - Unit testing Cloud Firestore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as admin from 'firebase-admin'; | |
let cachedAdmin: admin.app.App; | |
export function init(overrideApp?: admin.app.App) { | |
if (cachedAdmin) { | |
return; | |
} | |
cachedAdmin = overrideApp || admin.initializeApp(); | |
} | |
export function getAdmin() { | |
return cachedAdmin; | |
} | |
export function getFirestore() { | |
return cachedAdmin.firestore(); | |
} | |
export const FieldValue = admin.firestore.FieldValue; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment