Catch up on everything announced at Firebase Summit, and learn how Firebase can help you accelerate app development and run your app with confidence. Learn More

Firebase Test Lab triggers

Stay organized with collections Save and categorize content based on your preferences.

You can trigger a function in response to the completion of a test matrix in Firebase Test Lab. For example, you can notify a Slack channel or send an email if a test fails.

Trigger a function on TestMatrix completion

To trigger a Firebase Test Lab function, use the firebase-functions/v2/testLab subpackage. You can trigger functions when a TestMatrix completes with the onTestMatrixCompleted() event handler.

In this example, the function retrieves the TestMatrix data from the CloudEvent object and sends the corresponding test results to a Slack channel:

exports.posttestresultstoslack = onTestMatrixCompleted(
    {secrets: ["SLACK_WEBHOOK_URL"]},
    async (event) => {
    // Obtain Test Matrix properties from the CloudEvent
      const {testMatrixId, state, outcomeSummary} =;

      // Create the title of the message
      const title = `${getSlackmoji(state)} ${getSlackmoji(
      )} ${testMatrixId}`;

      // Create the details of the message
      const details = `Status: *${state}* ${getSlackmoji(
      )}\nOutcome: *${outcomeSummary}* ${getSlackmoji(outcomeSummary)}

      // Post the message to slack
      const slackResponse = await postToSlack(title, details);

      // Log the response

Access client details

Test matrices may be created from different sources or workflows. It is therefore often desirable to create functions that perform different actions based on the source or other important context of the test. To help with this, gcloud allows you to pass arbitrary information when starting a test that can be accessed later in your function. For example:

gcloud beta firebase test android run \
    --app=path/to/app.apk \
    --client-details testType=pr,link=<path/to/pull-request>