Skip to content

Quick Start

This guide walks you through creating a configuration file for sending automation test results to a Slack or Microsoft Teams or Google Chat.

slack-testbeats-pass

Results can be published to various targets via command line mode or configuration mode. Most of the documentation focuses on use of configuration mode which provides the most flexibility.

1. Prerequisites

1.1 Sign In to Portal (optional)

Don't have a testbeats account yet? Sign in for free with your Work Email at testbeats portal to have a centralized and AI powered reporting. Learn more about sign in options at portal introduction page. Once you're signed in, create a new organization and generate an API key.

Did you know?

If you have registered using your work email, users from your organization who share the same email domain will automatically gain access to the test results.

1.2 Prepare your Environment

Before you begin, ensure you have the following:

  • Node.js (optional) - If you choose to use npx, you can install Node.js and npm from the Node.js official website.
  • TestBeats Executable - If Node.js is not available, you can download the TestBeats executable for your operating system (Mac, Linux, or Windows).
sh
# Download the executable via `curl`.
curl https://raw.githubusercontent.com/test-results-reporter/testbeats/main/scripts/download-latest.sh | bash
  • Incoming Webhook URL - Create an incoming webhook url for your Slack or Microsoft Teams or Google Chat.

  • Test Results - The path of the test result files you want to publish.

2. Command Line Mode

Easiest way to send reports to a slack channel or any communication platform is via command line mode.

2.1 Publish Results

  • First, specify the target name using the appropriate target flag. For example, use the --slack flag to specify the incoming webhook URL.

  • Next, specify the path to the result files using the appropriate results format flag. For example, use the --junit flag for JUnit results or the --testng flag for TestNG results or the --cucumber flag for Cucumber results.

sh
npx testbeats@latest publish --api-key '<api-key>' --slack '<slack-incoming-webhook-url>' --junit '<path-to-junit-report>'
sh
# Download the executable via `curl`.
curl https://raw.githubusercontent.com/test-results-reporter/testbeats/main/scripts/download-latest.sh | bash

# After download completes, run the executable based on you operating system.
./testbeats-linux publish --api-key '<api-key>' --slack '<slack-incoming-webhook-url>' --junit '<path-to-junit-report>'

TIP

  • TestBeats API Key is optional.
  • Environment variable TEST_BEATS_API_KEY can also be used to specify the API key.

We should probably see the following output (for example):

sh
🥁 TestBeats v2.0.8
💻 NodeJS: v20.15.1, OS: linux, Version: 6.5.0-1024-azure, Arch: x86_64
🔔 Publishing results to Slack...
 Results published successfully!

slack-testbeats-failure-summary

Congratulations! You're now equipped with the true power of test result reporting as your test results are sliding into your communication platforms faster than a penguin on ice. Sit back and enjoy.

TIP

Click on the title of your test run to view detailed test results in the browser.

Read more about command line mode to learn more about other options.

3. Configuration Mode

Configuration mode is the most flexible mode. It allows you to customize the behavior of the reporter.

3.1 Create Configuration File

Create a new file, perhaps named config.json or even config.js. This configuration file adopts the JSON structure, utilizing key-value pairs for setting definitions. Throughout the documentation, JSON files are used for defining configuration.

json
{
  "api_key": "<api-key>",
}
  • api_key (string): test beats api key. Get it from testbeats.

TIP

  • TestBeats API Key is optional.
  • Environment variable TEST_BEATS_API_KEY can also be used to specify the API key.

3.2 Specify Test Results File

This section defines the test results files that the reporter will process.

  • type (string): This specifies format of the test results file. It supports various popular test results formats - junit, testng, cucumber, xunit, mocha, jmeter, etc.

  • files (array): This list contains the paths to your test results files. You can add multiple paths if you have multiple results files or use wildcard expressions.

You can find more details in the documentation Results.

json
{
  "api_key": "<api-key>",
  "results": [
    {
      "type": "testng",
      "files": [
        "path/to/testng-results.xml"
      ]
    }
  ]
}

3.3 Specify Targets

Target represents a specific platform where you want to share your test results, such as Slack or Microsoft Teams. In this case, we'll have one target: slack.

  • name (string): This specifies the name for this target. Set it to "slack".
  • inputs (object): This object contains configurations specific to the chosen target.
    • url (string): To send reports to a slack channel, we need to create a incoming webhook url. Follow this docs to create one.

You can find more details in the documentation Targets and Slack.

json
{
  "api_key": "<api-key>",
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "<slack-incoming-webhook-url>"
      }
    }
  ],
  "results": [
    {
      "type": "testng",
      "files": [
        "path/to/testng-results.xml"
      ]
    }
  ]
}

3.4 Publish Results

We can publish results either via curl, npx or npm

sh
# Directly execute via `npx`.
npx testbeats@latest publish -c path/to/config.json
sh
# Download the executable via `curl`.
curl https://raw.githubusercontent.com/test-results-reporter/testbeats/main/scripts/download-latest.sh | bash

# After download completes, run the executable based on you operating system.
./testbeats-linux publish -c path/to/config.json
js
// Install the package via `npm`.
// $ npm i testbeats

// Import the package into your `js` file.
const { publish, defineConfig } = require('testbeats');

const config = defineConfig({
  "api_key": "<api-key>",
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "<slack-incoming-webhook-url>"
      }
    }
  ],
  "results": [
    {
      "type": "testng",
      "files": [
        "path/to/testng-results.xml"
      ]
    }
  ]
});

publish({ config }).then(() => {
  console.log('Test results published successfully!');
}).catch((error) => {
  console.error('Failed to publish test results:', error);
});

// execute `node report.js` to generate report
// $ node report.js

slack-testbeats-failure-summary

Congratulations! You're now equipped with the true power of test result reporting as your test results are sliding into your communication platforms faster than a penguin on ice. Sit back and enjoy.

TIP

Click on the title of your test run to view detailed test results in the browser.

Released under the MIT License.