Socket
Book a DemoInstallSign in
Socket

firebase-functions-test

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firebase-functions-test

A testing companion to firebase-functions.

latest
Source
npmnpm
Version
3.4.1
Version published
Weekly downloads
221K
-12.89%
Maintainers
2
Weekly downloads
 
Created
Source

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

  • Write some Firebase Functions
  • With your testing framework of choice, write a unit-test that imports your Firebase Functions.
  • 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.

Keywords

firebase

FAQs

Package last updated on 10 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts