{"id":20137077,"url":"https://github.com/ctrf-io/slack-test-reporter","last_synced_at":"2025-04-09T07:08:09.849Z","repository":{"id":242149623,"uuid":"808347420","full_name":"ctrf-io/slack-test-reporter","owner":"ctrf-io","description":"Send Slack notifications with test results from popular testing frameworks using a single command in your CI/CD","archived":false,"fork":false,"pushed_at":"2025-03-16T18:21:28.000Z","size":831,"stargazers_count":28,"open_issues_count":4,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T03:55:02.884Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ctrf.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctrf-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-30T22:06:17.000Z","updated_at":"2025-03-25T20:30:57.000Z","dependencies_parsed_at":"2024-06-20T05:19:41.877Z","dependency_job_id":"0043d758-d19a-4ec3-b320-f41ac8ce63f9","html_url":"https://github.com/ctrf-io/slack-test-reporter","commit_stats":null,"previous_names":["ctrf-io/slack-ctrf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrf-io%2Fslack-test-reporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrf-io%2Fslack-test-reporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrf-io%2Fslack-test-reporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrf-io%2Fslack-test-reporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctrf-io","download_url":"https://codeload.github.com/ctrf-io/slack-test-reporter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994121,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T21:25:05.334Z","updated_at":"2025-04-09T07:08:09.821Z","avatar_url":"https://github.com/ctrf-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slack Test Results Notification\n\n\u003e Send Slack message with test results from popular testing frameworks\n\nA Slack test reporting tool that supports all major testing frameworks.\nGenerate, publish and alert your team with detailed test results, including\nsummaries, in-depth reports, failed test analyses, flaky test detection and AI\nanalyses directly to your chosen Slack channel.\n\n\u003cdiv align=\"center\"\u003e\n\u003cdiv style=\"padding: 1.5rem; border-radius: 8px; margin: 1rem 0; border: 1px solid #30363d;\"\u003e\n\u003cspan style=\"font-size: 23px;\"\u003e💚\u003c/span\u003e\n\u003ch3 style=\"margin: 1rem 0;\"\u003eCTRF tooling is open source and free to use\u003c/h3\u003e\n\u003cp style=\"font-size: 16px;\"\u003eYou can support the project with a follow and a star\u003c/p\u003e\n\n\u003cdiv style=\"margin-top: 1.5rem;\"\u003e\n\u003ca href=\"https://github.com/ctrf-io/slack-test-reporter\"\u003e\n\u003cimg src=\"https://img.shields.io/github/stars/ctrf-io/slack-test-reporter?style=for-the-badge\u0026color=2ea043\" alt=\"GitHub stars\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/ctrf-io\"\u003e\n\u003cimg src=\"https://img.shields.io/github/followers/ctrf-io?style=for-the-badge\u0026color=2ea043\" alt=\"GitHub followers\"\u003e\n\u003c/a\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cp style=\"font-size: 14px; margin: 1rem 0;\"\u003e\nMaintained by \u003ca href=\"https://github.com/ma11hewthomas\"\u003eMatthew Thomas\u003c/a\u003e\u003cbr/\u003e\nContributions are very welcome! \u003cbr/\u003e\nExplore more \u003ca href=\"https://www.ctrf.io/integrations\"\u003eintegrations\u003c/a\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n## Features\n\n- **Send Test Results to Slack**: Automatically send test results to a Slack channel.\n- **Send Flaky Test Details to Slack**: Automatically send flaky test details to a Slack channel.\n- **Send AI Test Summary to Slack**: Automatically send AI test summary to a Slack channel.\n- **Send Failed Test Details to Slack**: Automatically send failed test details to a Slack channel.\n- **Build your own Slack message**: Create and customize your own Slack test reports with our flexible templating system.\n- **Tagging**: Tag users, channels and groups in the message.\n- **Conditional Notifications**: Use the `--onFailOnly` option to send notifications only if tests fail.\n\n![Example view](assets/results.png)\n\n## Setup\n\nYou'll need a CTRF report generated by your testing framework. [CTRF reporters](https://github.com/orgs/ctrf-io/repositories) are available for most testing frameworks and easy to install.\n\n**No CTRF reporter? No problem!**\n\nUse [junit-to-ctrf](https://github.com/ctrf-io/junit-to-ctrf) to convert a JUnit report to CTRF.\n\n### Create a Slack Incoming Webhook\n\n1. Go to the [Slack API: Incoming Webhooks](https://api.slack.com/messaging/webhooks) page.\n2. Click on \"Create a Slack App\" or use an existing app.\n3. Add the \"Incoming Webhooks\" feature to your app.\n4. Activate the Incoming Webhook and add a new webhook to your workspace.\n5. Copy the webhook URL provided.\n\n### Set the Environment Variable\n\nSet the webhook URL as an environment variable in your shell or CI environment:\n\n```sh\nexport SLACK_WEBHOOK_URL='https://hooks.slack.com/services/your/webhook/url'\n```\n\nMake sure to replace `'https://hooks.slack.com/services/your/webhook/url'` with your actual webhook URL.\n\nYou might want to store the webhook URL as a secret.\n\n## Usage\n\nYou can use a glob pattern or a single file path to send the test results summary to Slack.\n\n### Results\n\nTo send the test results summary to Slack:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-report.json\n```\n\nYou can use a glob pattern with multiple files which will be merged together:\n\n```sh\nnpx slack-ctrf results \"ctrf/*.json\"\n```\n\n![Results view](assets/results.png)\n\n### AI Summary\n\nTo send AI failed test summary to Slack:\n\n```sh\nnpx slack-ctrf ai /path/to/ctrf-report.json\n```\n\nUse `--consolidated` argumement to send a single message with all AI summaries\n\n```sh\nnpx slack-ctrf ai /path/to/ctrf-report.json --consolidated\n```\n\n![AI view](assets/ai.png)\n\nSee the [AI Test Reporter](https://github.com/ctrf-io/ai-test-reporter) to add AI summaries to your CTRF report\n\n### Flaky\n\nTo send flaky test report to Slack:\n\n```sh\nnpx slack-ctrf flaky /path/to/ctrf-report.json\n```\n\n![Flaky view](assets/flaky.png)\n\n## Failed\n\nTo send failed test report to Slack:\n\n```sh\nnpx slack-ctrf failed /path/to/ctrf-report.json\n```\n\nUse `--consolidated` argumement to send a single message with all AI summaries\n\n```sh\nnpx slack-ctrf failed /path/to/ctrf-report.json --consolidated\n```\n\n![Failed view](assets/failed.png)\n\n## Build your own Slack message\n\nThe `custom` method lets you build your own report using a Handlebars\ntemplate allowing you to leverage data from your CTRF report to build a dynamic Slack message. The template can be a Block Kit JSON or Slack flavored markdown context block.\n\nTo send a message to Slack using a custom Handlebars template:\n\n```sh\nnpx slack-ctrf custom /path/to/ctrf-report.json /path/to/template.hbs --blockkit\n```\n\n```sh\nnpx slack-ctrf custom /path/to/ctrf-report.json /path/to/template.hbs --markdown\n```\n\nThe template has access to the entire CTRF report data through the `ctrf` variable. For example:\n\n```handlebars\nTests: {{ctrf.summary.tests}}\n```\n\n```markdown\nTests: 100\n```\n\n### Block Kit JSON\n\nProvide a Block Kit JSON template to the `--blockkit` option. See the [Slack Block Kit Documentation](https://api.slack.com/block-kit) and [Slack Block Kit Builder](https://api.slack.com/tools/block-kit-builder) for help creating a template.\n\nThe Block Kit JSON template can include Handlebars syntax to access test report data. For example:\n\n```json\n{\n  \"blocks\": [\n    {\n      \"type\": \"header\",\n      \"text\": {\n        \"type\": \"plain_text\",\n        \"text\": \"Test Results: {{ctrf.summary.total}} tests run\"\n      }\n    },\n    {\n      \"type\": \"section\",\n      \"text\": {\n        \"type\": \"mrkdwn\",\n        \"text\": \"*Passed:* {{ctrf.summary.passed}}\\n*Failed:* {{ctrf.summary.failed}}\"\n      }\n    }\n  ]\n}\n```\n\nSee the [templates](templates) directory for examples.\n\n### Slack Flavored Markdown\n\nProvide a Slack flavored markdown template to the `--markdown` option. See the [Slack Flavored Markdown Documentation](https://api.slack.com/block-kit) for help creating a template.\n\nSee the [templates](templates) directory for examples.\n\n### Handlebars\n\nHandlebars is a simple templating language that lets you insert data into your\nmessage in a declarative way. You can use placeholders, conditionals, and loops\nto dynamically generate content based on your test results.\n\n## CTRF Properties\n\nThe `ctrf` object provides access to your test results data. Here are the common\nproperties:\n\n### Summary (`ctrf.summary`)\n\n- `tests`: Total number of tests\n- `passed`: Number of passed tests\n- `failed`: Number of failed tests\n- `skipped`: Number of skipped tests\n- `start`: Test suite start time\n- `stop`: Test suite end time\n\n### Individual Tests (`ctrf.tests`)\n\nAn array of test results, each containing:\n\n- `name`: Test name\n- `status`: Test status (\"passed\", \"failed\", \"skipped\")\n- `message`: Test output/error message\n- `duration`: Test duration in milliseconds\n- `retries`: Number of retries (for flaky tests)\n\nExample accessing test data:\n\n```hbs\n{{#each ctrf.tests}}\n  Test: {{this.name}} - Status: {{this.status}}\n{{/each}}\n```\n\n### Helpers\n\nThe template can include helpers to format the data. See the [handlebars built-in helpers](https://handlebarsjs.com/guide/#helpers) and custom [helpers](src/handlebars/helpers) directory for the available helpers.\n\n## Send Only on Failures\n\nTo send the test results summary to Slack only if there are failed tests, use the `--onFailOnly` option:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-file.json --onFailOnly\n```\n\nor using the alias:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-file.json -f\n```\n\n## Custom Notification Title\n\nYou can choose a custom title for your notification, use the `--title` option:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-file.json --title \"Custom Title\"\n```\n\nor using the alias:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-file.json -t \"Custom Title\"\n```\n\n## Add Prefix and Suffix\n\nAdd custom markdown text to as a prefix, or suffix to the message:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-file.json -p \"prefix\" -s \"suffix\"\n```\n\nRead about compatible [markdown](https://api.slack.com/reference/surfaces/formatting#basic-formatting)\n\n## Tagging a user, channel or group\n\nYou can tag users, channels or groups in the message by using the `--prefix` or `--suffix` options.\n\nYou need to a Slack user ID, channel ID or group ID.\n\nYou can find your user ID by:\n\n- Clicking on your profile picture in Slack\n- Clicking the three dots (...)\n- Selecting \"Copy member ID\"\n\nOnce you have your user ID (which will look something like U01ABC123DE), use that in your command instead of your display name:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-file.json -s \"\u003c@U0123456789\u003e please review the results\"\n```\n\nYou can also tag a channel by using the `#` symbol with the channel ID:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-file.json -s \"\u003c#C0123456789\u003e please review the results\"\n```\n\nAnd finally, you can tag a group by using the `\\!subteam^` symbol with the group ID:\n\n```sh\nnpx slack-ctrf results /path/to/ctrf-file.json -s \"\u003c\\!subteam^0123456789\u003e please review the results\"\n```\n\n## Options\n\n- `--onFailOnly, -f`: Send notification only if there are failed tests.\n- `--title, -t`: Title of the notification.\n- `--prefix, -p`: Custom markdown text to add as a prefix to the message\n- `--suffix, -p`: Custom markdown text to add as a prefix to the message\n\n## Merge reports\n\nYou can merge reports if your chosen reporter generates multiple reports through design, parallelisation or otherwise.\n\nIf you use a glob pattern, the reports will be merged automatically.\n\nOtherwise, the [ctrf-cli](https://github.com/ctrf-io/ctrf-cli) package provides a method to merge multiple ctrf json files into a single file.\n\nAfter executing your tests, use the following command:\n\n```sh\nnpx ctrf merge \u003cdirectory\u003e\n```\n\nReplace directory with the path to the directory containing the CTRF reports you want to merge.\n\n## Programmatic Usage\n\nYou can use the package programmatically to send notifications to Slack. To install the package, run:\n\n```sh\nnpm install slack-ctrf\n```\n\nThe package exports the following functions:\n\n- `sendTestResultsToSlack`\n- `sendFlakyResultsToSlack`\n- `sendFailedResultsToSlack`\n- `sendAISummaryToSlack`\n- `sendCustomMarkdownTemplateToSlack`\n- `sendCustomBlockKitTemplateToSlack`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctrf-io%2Fslack-test-reporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctrf-io%2Fslack-test-reporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctrf-io%2Fslack-test-reporter/lists"}