Skip to content

Configuration Reference ​

Complete reference for TestBeats configuration options and file structure.

Configuration File ​

The configuration file (.testbeats.json) provides the most flexible way to configure TestBeats:

json
{
  "api_key": "<your-api-key>",
  "project": "my-awesome-project",
  "run": "Build 123 - main",
  "results": [
    {
      "type": "junit",
      "files": ["**/test-results.xml"]
    }
  ],
  "targets": [
    {
      "name": "slack",
      "condition": "fail",
      "inputs": {
        "url": "<slack-webhook-url>",
        "publish": "failure-details"
      }
    }
  ],
  "extensions": [
    {
      "name": "mentions",
      "inputs": {
        "users": ["[email protected]"]
      }
    }
  ],
  "metadata": {
    "environment": "production",
    "team": "payments"
  }
}

Top-Level Properties ​

PropertyTypeRequiredDescription
api_keystringNoTestBeats Portal API key
projectstringNoProject identifier
runstringNoRun identifier or description
resultsarrayYesTest result sources
targetsarrayNoCommunication targets configuration
extensionsarrayNoAdditional processing extensions
metadataobjectNoMetadata for the test run

Results Configuration ​

Define where TestBeats should find test results:

json
{
  "type": "junit",
  "files": ["**/test-results.xml", "reports/*.xml"]
}

Result Properties ​

PropertyTypeRequiredDescription
typestringYesResult format (junit, testng, mocha, etc.)
filesarrayYesFile paths or glob patterns

Supported Formats ​

Automation Test Results ​

  • cucumber - Cucumber JSON format
  • junit - JUnit XML format
  • mocha - Mocha JSON format
  • mstest - MSTest TRX format
  • nunit - NUnit XML format
  • testng - TestNG XML format
  • xunit - xUnit XML format

Performance Test Results ​

  • jmeter - JMeter XML format

Targets Configuration ​

Each target represents a communication channel or data destination:

json
{
  "name": "slack",
  "enable": true,
  "condition": "fail",
  "inputs": {
    "url": "https://hooks.slack.com/services/...",
    "publish": "test-summary"
  }
}

Target Properties ​

PropertyTypeRequiredDescription
namestringYesTarget type (slack, teams, chat, etc.)
enablebooleanNoWhether to enable this target
conditionstringNoWhen to send notifications
inputsobjectYesTarget-specific configuration
extensionsarrayNoLocal extensions for this target

Extensions Configuration ​

Add additional processing capabilities:

json
{
  "name": "mentions",
  "enable": true,
  "condition": "fail",
  "hook": "after-summary",
  "order": 1,
  "inputs": {
    "users": ["[email protected]"],
    "teams": ["dev-team"]
  }
}

Extension Properties ​

PropertyTypeRequiredDescription
namestringYesExtension type
enablebooleanNoWhether to enable this extension
hookstringNoWhen to apply extension (start, after-summary, end)
ordernumberNoOrder of execution
conditionstringNoWhen to apply extension
inputsobject-Extension-specific configuration

Metadata Configuration ​

Metadata is a way to add additional information to the test run. It is a key-value pair that can be used to add additional information to the test run.

json
{
  "metadata": {
    "environment": "production",
    "team": "payments"
  }
}

Metadata Properties ​

It is a key-value pair that can be used to add additional information to the test run.

PropertyTypeRequiredDescription
environmentstringNoEnvironment of the test run
teamstringNoTeam of the test run
dataobjectNoData to be added to the test run
  • key (string) - Key of the data
  • value (string) - Value of the data

Conditions ​

Conditions allows teams to fine-tune the publishing process to meet their specific needs, ensuring that they receive only the information they require in real-time.

We can specify the conditions under which each target or extension to run. By default, a target or extension will have default condition tied to the test results. For example, targets like slack or teams will run for all the test runs and extensions like report-portal-analysis or mentions will only run when there are test failures.

Condition (Test Results) ​

  • pass
  • fail
  • passOrFail
  • always
  • never
  • function
json
{
  "targets": [
    {
      "name": "teams",
      "condition": "pass",
      "inputs": {
        "url": "<teams-success-channel-incoming-webhook-url>"
      }
    },
    {
      "name": "teams",
      "condition": "fail",
      "inputs": {
        "url": "<teams-failure-channel-incoming-webhook-url>"
      }
    }
  ],
  "results": [
    {
      "type": "testng",
      "files": ["path/to/testng-results.xml"]
    }
  ]
}

Condition (Dynamic) ​

Conditions can also support javascript expressions that returns a boolean. For example, take a look at enabling a extension based on environment variable GIT_BRANCH.

json
{
  "targets": [
    {
      "name": "teams",
      "inputs": {
        "url": "<teams-incoming-webhook-url>"
      },
      "extensions": [
        {
          "name": "mentions",
          "condition": "{GIT_BRANCH} === 'main'",
          "inputs": {
            "users": [
              {
                "name": "Jon",
                "teams_upn": "[email protected]"
              }
            ]
          }
        }
      ]
    }
  ],
  "results": [
    {
      "type": "testng",
      "files": ["path/to/testng-results.xml"]
    }
  ]
}

Condition (Function) ​

The function should return a boolean and it can be asynchronous.

js
const config = {
  targets: [
    {
      name: "teams",
      condition: async ({ target, result }) => {
        return result.failed > 2;
      },
      inputs: {
        url: "<teams-failure-channel-incoming-webhook-url>",
      },
    },
  ],
  results: [
    {
      type: "testng",
      files: ["path/to/testng-results.xml"],
    },
  ],
};

Command-Line Override ​

Command-line arguments override configuration file values:

bash
# Configuration file specifies Slack, but command overrides with Teams
npx testbeats publish -c config.json --teams $TEAMS_WEBHOOK

Configuration Examples ​

Simple Slack Notification ​

json
{
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "${SLACK_WEBHOOK_URL}"
      }
    }
  ],
  "results": [
    {
      "type": "junit",
      "files": ["test-results.xml"]
    }
  ]
}

Multi-Target with Conditions ​

json
{
  "targets": [
    {
      "name": "slack",
      "condition": "fail",
      "inputs": {
        "url": "${SLACK_WEBHOOK_URL}",
        "publish": "failure-details"
      }
    },
    {
      "name": "teams",
      "inputs": {
        "url": "${TEAMS_WEBHOOK_URL}",
        "publish": "test-summary-slim"
      }
    }
  ],
  "results": [
    {
      "type": "junit",
      "files": ["**/junit.xml"]
    }
  ]
}

Complete Configuration ​

json
{
  "api_key": "${TESTBEATS_API_KEY}",
  "project": "${CI_PROJECT_NAME}",
  "run": "Build ${CI_PIPELINE_ID} - ${CI_COMMIT_REF_NAME}",
  "targets": [
    {
      "name": "slack",
      "condition": "fail",
      "inputs": {
        "url": "${SLACK_WEBHOOK_URL}",
        "publish": "failure-details",
        "title": "🚨 Test Failures",
        "title_link": "${CI_PIPELINE_URL}",
        "only_failures": true
      }
    },
    {
      "name": "teams",
      "inputs": {
        "url": "${TEAMS_WEBHOOK_URL}",
        "publish": "test-summary",
        "title": "📊 Test Results"
      }
    }
  ],
  "results": [
    {
      "type": "junit",
      "files": ["**/test-results.xml", "**/junit.xml"]
    }
  ],
  "extensions": [
    {
      "name": "mentions",
      "condition": "fail",
      "inputs": {
        "users": ["[email protected]"],
        "teams": ["qa-team"]
      }
    },
    {
      "name": "hyperlinks",
      "inputs": {
        "links": [
          {
            "text": "View Build",
            "url": "${CI_PIPELINE_URL}"
          }
        ]
      }
    }
  ]
}

Released under the MIT License.