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:
- CLI Mode - using command line arguments
- 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.
Option | Description | Section | Required? |
---|---|---|---|
-h, --help | Display help information | Config | Optional |
-c, --config <path> | Path to configuration file (default: .testbeats.json ) | Config | Optional |
-v, --verbose | Enable verbose logging | Config | Optional |
--api-key <key> | TestBeats API key | Portal | Optional |
--project <name> | Project name | Portal | Optional |
--run <name> | Run name | Portal | Optional |
--slack <url> | Slack incoming webhook URL | Targets | Optional |
--teams <url> | MS Teams incoming webhook URL | Targets | Optional |
--chat <url> | Google Chat incoming webhook URL | Targets | Optional |
--junit <path> | Path to JUnit report | Results | Optional |
--cucumber <path> | Path to Cucumber report | Results | Optional |
--mocha <path> | Path to Mocha report | Results | Optional |
--testng <path> | Path to TestNG report | Results | Optional |
--xunit <path> | Path to xUnit report | Results | Optional |
--nunit <path> | Path to NUnit report | Results | Optional |
--mstest <path> | Path to MSTest report | Results | Optional |
--ci-info | Show CI information | Extensions | Optional |
--chart-test-summary | Show Quick chart summary | Extensions | Optional |
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"]
}
]
}