Skip to content

Publish ​

The publish command is used to send test results to configured targets like Slack, MS Teams, Google Chat, etc. It reads the test results from files and publishes them according to the configuration.

Usage ​

The publish command can be used in two modes:

  1. CLI Mode - using command line arguments
  2. Configuration Mode - using a JSON configuration file

CLI Mode ​

bash
npx testbeats@latest publish [options]

CLI Options ​

Command line options are used to configure the behavior of the reporter. You can also use them to provide additional information to the reporter.

OptionDescriptionSectionRequired?
-h, --helpDisplay help informationConfigOptional
-c, --config <path>Path to configuration file (default: .testbeats.json)ConfigOptional
-v, --verboseEnable verbose loggingConfigOptional
--api-key <key>TestBeats API keyPortalOptional
--project <name>Project namePortalOptional
--run <name>Run namePortalOptional
--slack <url>Slack incoming webhook URLTargetsOptional
--teams <url>MS Teams incoming webhook URLTargetsOptional
--chat <url>Google Chat incoming webhook URLTargetsOptional
--junit <path>Path to JUnit reportResultsOptional
--cucumber <path>Path to Cucumber reportResultsOptional
--mocha <path>Path to Mocha reportResultsOptional
--testng <path>Path to TestNG reportResultsOptional
--xunit <path>Path to xUnit reportResultsOptional
--nunit <path>Path to NUnit reportResultsOptional
--mstest <path>Path to MSTest reportResultsOptional
--ci-infoShow CI informationExtensionsOptional
--chart-test-summaryShow Quick chart summaryExtensionsOptional

Examples ​

sh
# Basic with Portal
npx testbeats@latest publish --api-key '<testbeats-api-key>' --slack '<slack-incoming-webhook-url>' --junit '<path-to-junit-report>'

# Publish junit results to slack
npx testbeats@latest publish --slack '<slack-incomming-webhook-url>' --junit "test-results/*.xml"

# Publish results to multiple targets
npx testbeats@latest publish --slack '<slack-incoming-webhook-url>' --teams '<teams-incoming-webhook-url>' --junit '<path-to-junit-report>'

# Publish tests results including additiona details with extensions
npx testbeats@latest publish --ci-info --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>'

Configuration Mode ​

Use a JSON configuration file to specify targets, results, and extensions.

bash
# Using config file
npx testbeats@latest publish -c ./config/report.json

Examples ​

json
// A basic example of a configuration file that publishes test results to Slack
{
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "<slack-webhook-url>"
      }
    }
  ],
  "results": [
    {
      "type": "junit",
      "files": ["test-results/*.xml"]
    }
  ]
}
json
// Example showing publish with CI info and test summary chart
{
  "targets": [
    {
      "name": "teams",
      "inputs": {
        "url": "<teams-webhook-url>"
      },
      "extensions": [
        {
          "name": "ci-info"
        },
        {
          "name": "quick-chart-test-summary"
        }
      ]
    }
  ],
  "results": [
    {
      "type": "testng",
      "files": ["target/surefire-reports/testng-results.xml"]
    }
  ]
}
json
// You can publish to multiple targets in a single configuration
{
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "<slack-webhook-url>"
      }
    },
    {
      "name": "teams",
      "inputs": {
        "url": "<teams-webhook-url>"
      }
    }
  ],
  "results": [
    {
      "type": "mocha",
      "files": ["test-results/results.json"]
    }
  ]
}
json
// You can use environment variables in your configuration by wrapping them in curly braces
{
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "{SLACK_WEBHOOK_URL}"
      }
    }
  ],
  "results": [
    {
      "type": "junit",
      "files": ["test-results/*.xml"]
    }
  ]
}

See Also ​

Released under the MIT License.