firebase / firebase-functions-test

MIT License
231 stars 48 forks source link

Add testing support for 2nd gen firestore triggers #200

Closed blidd-google closed 1 year ago

blidd-google commented 1 year ago

2nd gen firestore triggers support is coming soon! This PR will add support for mocking 2nd gen firestore triggers.

Example:

// index.ts
import { onDocumentCreated } from "firebase-functions/v2/firestore";

export const fn = onDocumentCreated("foo/{bar}", (event) => {...});

// index.test.ts
import * as test from "firebase-functions-test";
import { fn } from './index';

const {wrap} = test();
const wrappedFn = wrap(fn);
wrappedFn({
  data: {
    a: 'b',
    c: 'd',
  },
  params: {
    bar: 123,
  },
});