Need private packages and team management tools?Check out npm Teams »

firebase-mock-functions

0.2.3 • Public • Published

firebase-mock-functions

Test your Firebase database triggers offline

Installation

npm install --save-dev firebase-mock-functions

Example usage

var chai = require('chai');
chai.use(require('chai-as-promised'));
 
var FakeDatabase = require('firebase-mock-functions');
var functions = require('firebase-functions');
var admin = require('firebase-admin');
var db = new FakeDatabase(functions, admin);
db.override();
db.database.autoFlush(true);
 
// Your Firebase functions "index.js".
// This contains a function which sums /items values and saves to /total
var index = require('index');
 
db.setFunctionsModule(index);
 
describe('count total', function() {
 
  beforeEach(function() {
    return db.setWithoutTriggers('/', { items: { one: 1, two: 2}, total: 3 });
  });
 
  it('updates "/total" when a new item is added', function() {
    return db.write('/items/three', 3)
    .then(function() { return db.value('/total') })
    .should.eventually.equal(6);
  });
 
});

Install

npm i firebase-mock-functions

DownloadsWeekly Downloads

0

Version

0.2.3

License

MIT

Last publish

Collaborators

  • avatar