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 cli mode or configuration mode. Most of the documentation focuses on use of configuration mode which provides the most flexibility.

0. Prerequisites (optional) ​

Don't have a testbeats account yet? Sign in for free with your work email at testbeats portal to have a centralized reporting and ai analysis. 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.1 CLI Mode ​

Easiest way to send reports to a slack channel is via cli mode. First, you need to create a incoming webhook url. Follow these instructions to create one. 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 or the --testng flag for TestNG.

sh
npx testbeats@latest publish --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 --slack '<slack-incoming-webhook-url>' --junit '<path-to-junit-report>'

Read more about cli mode.

2.1 Configuration Mode (Create Config 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.

Environment variable TEST_BEATS_API_KEY can also be used.

2.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"
      ]
    }
  ]
}

2.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"
      ]
    }
  ]
}

2.4 Publishing 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
sh
# 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>",
  "project": "Order App",
  "run": "UI Smoke Test",
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "<slack-incoming-webhook-url>"
      }
    }
  ],
  "results": [
    {
      "type": "testng",
      "files": [
        "path/to/testng-results.xml"
      ]
    }
  ]
});

await publish({ config });

# 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 Slack 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.