Skip to content

Slack Target Reference ​

Send test results to Slack channels using incoming webhooks.

Prerequisites ​

Create a Slack incoming webhook URL by following the official Slack documentation.

Configuration ​

Basic Configuration ​

json
{
  "name": "slack",
  "inputs": {
    "url": "<slack-incoming-webhook-url>"
  }
}

Complete Configuration ​

json
{
  "name": "slack",
  "condition": "fail",
  "inputs": {
    "url": "<slack-incoming-webhook-url>",
    "publish": "test-summary",
    "only_failures": false,
    "title": "Custom Test Results",
    "title_link": "https://ci.example.com/build/123",
    "title_suffix": " - Production",
    "max_suites": 15,
    "message_format": "attachments"
  }
}

Properties ​

PropertyTypeDescriptionDefault
urlstringSlack incoming webhook URLRequired
publishstringReport type to publish"test-summary"
only_failuresbooleanShow only failed testsfalse
titlestringCustom report titleAuto-generated
title_linkstringClickable link on titleNone
title_suffixstringText appended to titleNone
max_suitesnumberMaximum suites to display10
message_formatstringSlack message format"attachments"

Report Types ​

test-summary ​

Complete test results with suite breakdown and metrics.

Single Test Suite:Single Suite

Multiple Test Suites:Multiple Suites

test-summary-slim ​

Condensed results without suite details. Perfect for keeping primary channels clean.

Slim Summary

failure-details ​

Detailed information about failed tests including error messages and stack traces.

Failure Details

Message Formats ​

FormatDescription
"attachments"Legacy Slack attachments (default)
"blocks"Modern Slack Block Kit format

Command Line Usage ​

Basic Usage ​

bash
npx testbeats@latest publish \
  --slack '<webhook-url>' \
  --junit '<report-path>'

With Options ​

bash
npx testbeats@latest publish \
  --slack '<webhook-url>' \
  --junit '<report-path>' \
  --api-key '<api-key>'

Configuration File Examples ​

Development Team Channel ​

json
{
  "targets": [
    {
      "name": "slack",
      "condition": "fail",
      "inputs": {
        "url": "<dev-channel-webhook>",
        "publish": "failure-details",
        "title": "🚨 Test Failures",
        "only_failures": true
      }
    }
  ]
}

Management Dashboard ​

json
{
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "<management-channel-webhook>",
        "publish": "test-summary-slim",
        "title": "📊 Daily Test Report",
        "message_format": "blocks"
      }
    }
  ]
}

Multiple Environments ​

json
{
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "<staging-webhook>",
        "title_suffix": " - Staging"
      }
    },
    {
      "name": "slack",
      "inputs": {
        "url": "<production-webhook>",
        "title_suffix": " - Production",
        "publish": "test-summary-slim"
      }
    }
  ]
}

Extensions Support ​

Slack targets support all TestBeats extensions:

Troubleshooting ​

Common Issues ​

Webhook URL not working:

  • Verify the webhook URL is correct and active
  • Test the webhook URL manually using curl
  • Check Slack app permissions

Messages not appearing:

  • Ensure the bot has permission to post in the channel
  • Verify the webhook is associated with the correct workspace
  • Check Slack's rate limiting

Formatting issues:

  • Try switching between "attachments" and "blocks" message formats
  • Verify special characters are properly escaped
  • Check message size limits

Testing Configuration ​

bash
# Test with minimal configuration
npx testbeats@latest publish \
  --slack '<webhook-url>' \
  --junit '<sample-report>' \
  --verbose

Released under the MIT License.