Skip to content

Instantly share code, notes, and snippets.

View pejalo's full-sized avatar

pejalo

  • Pennsylvania
View GitHub Profile
@pejalo
pejalo / testing.js
Last active April 7, 2020 13:49
Setup for testing HTTP-triggered Firebase Functions locally
const functions = require('firebase-functions'); // To stub config()
const admin = require('firebase-admin'); // To get credential cert for initializeApp
const firebase = require('firebase'); // To sign in test user and test database writes
const assert = require('chai').assert;
const sinon = require('sinon');
// https://firebase.google.com/docs/functions/unit-testing
// The functions make use of 'firebase-admin', whereas client-side code uses 'firebase'.
// We initialze 'firebase' here to mock client-side code.