Coder Social home page Coder Social logo

firebase-functions-test's Introduction

Firebase Test SDK for Cloud Functions

The firebase-functions-test is unit testing library for Cloud Functions for Firebase. It is a companion to firebase-functions.

NOTE: This library can only be used with firebase-functions v3.20.1 or above.

Usage

  1. Write some Firebase Functions
  2. With your testing framework of choice, write a unit-test that imports your Firebase Functions.
  3. wrap your Firebase Functions. You can invoke the Firebase Function's handler by invoking the wrap call.

Eg.

import {myFirebaseFunction} from "../index"; // Your Firebase Functions
import firebaseFunctionsTest from "firebase-functions-test";

// Extracting `wrap` out of the lazy-loaded features
const {wrap} = firebaseFunctionsTest();

// `jest-ts` example
test('my unit test', () => {
  const wrappedFirebaseFunction = wrap(myFirebaseFunction);

  // Invoke the firebase function
  wrappedFirebaseFunction();

  // Invoke the firebase function with CloudEvent overrides
  wrappedFirebaseFunction({data: {arbitrary: 'values'}});
});

Examples

Learn more

Learn more about unit testing Cloud Functions here.

Contributing

To contribute a change, check out the contributing guide.

License

© Google, 2018. Licensed under The MIT License.

firebase-functions-test's People

Contributors

laurenzlong avatar google-oss-bot avatar theirondev avatar firebase-ops avatar dependabot[bot] avatar inlined avatar bkendall avatar shoeboom avatar taeold avatar joehan avatar rhodgkins avatar abeisgoat avatar dackers86 avatar salakar avatar morganchen12 avatar rohantalip avatar saygun avatar prescottprue avatar the0rem avatar sceee avatar vikrum avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.