Skip to content

Instantly share code, notes, and snippets.

@danahartweg
Created October 15, 2019 22:28
Show Gist options
  • Save danahartweg/1b25e0bf34d905914934f4948f9f2f86 to your computer and use it in GitHub Desktop.
Save danahartweg/1b25e0bf34d905914934f4948f9f2f86 to your computer and use it in GitHub Desktop.
Function admin helper - Unit testing Cloud Firestore
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