Skip to content

Files

Latest commit

95c7752 · Jun 5, 2025

History

History
Cannot retrieve ahead/behind information for this branch.

Folders and files

NameName
Last commit message
Last commit date
Mar 10, 2025
May 5, 2022
May 30, 2025
May 30, 2025
Apr 8, 2024
Feb 26, 2020
Jan 6, 2020
Mar 10, 2025
Apr 2, 2018
Jun 5, 2025
May 19, 2025
Mar 10, 2025
Jan 6, 2020
Jan 6, 2020
Jan 6, 2020

README.md

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.22.0 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.