k6-slack-ms-teams-reporter
v1.0.5
Published
A K6 test results reporter that sends HTML reports as attachments to Slack and Microsoft Teams
Maintainers
Readme
📖 k6-slack-ms-teams-reporter
🚀 A lightweight reporting tool that sends K6 Load Test Reports to Slack & Microsoft Teams.
📌 Features
✔ Parses K6 JSON or HTML reports
✔ Extracts failure rate, iteration stats & threshold breaches
✔ Sends results directly to Slack or Teams
✔ Customizable message format & colors
✔ Works in CI/CD pipelines (GitHub Actions, GitLab CI, Jenkins, etc.)
📋 Prerequisites
Before using this package, ensure you have the following installed:
1️⃣ Node.js (>=18.x) - Download
2️⃣ NPM (Comes with Node.js)
3️⃣ K6 for load testing - Install K6
4️⃣ Slack & Teams Webhook URLs (Saved in .env)
📦 Installation
npm install --save-dev k6-slack-ms-teams-reporter🔧 Configuration
1️⃣ Set Up Environment Variables
Create a .env file and add your Slack or Teams webhook URL:
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/your-webhook-url
TEAMS_WEBHOOK_URL=https://outlook.office.com/webhook/your-webhook-url📊 Generating Reports
To generate HTML and JSON reports, modify your K6 script:
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
export function handleSummary(data) {
return {
"reports/k6TestReport.html": htmlReport(data),
"reports/k6TestResults.json": JSON.stringify(data),
stdout: textSummary(data, { indent: " ", enableColors: true }),
};
}This will create:
📜 HTML Report: reports/k6TestReport.html
📜 JSON Report: reports/k6TestResults.json
🚀 Sending Reports
1️⃣ CLI Usage
Send Report to Slack
npx k6-slack-ms-teams-reporter --target slack --report-name k6TestResultsSend Report to Microsoft Teams
npx k6-slack-ms-teams-reporter --target teams --report-name k6TestResults🛠️ Custom Reporter Options
You can configure custom options via reportConfig.json:
Create a reportConfig.json file in your project:
{
"target": "slack",
"reportName": "k6TestResults",
"verbose": true,
"jsonReportPath": "artifacts/loadTestResults.json",
"htmlReportUrl": "artifacts/loadTestReport.html",
"ciPipelineUrl": "https://gitlab.com/myproject/-/jobs/"
}Users can also create a reportConfig.js file like this:
export default {
reporter: "k6-slack-ms-teams-reporter",
target: "slack",
reportName: "k6TestResults",
verbose: false,
jsonReportPath: "examples/reports/k6TestResults.json",
htmlReportUrl: "http://127.0.0.1/examples/reports/k6TestResults.html",
ciPipelineUrl: "https://gitlab.com/myproject/-/jobs/",
};Then run the reporter:
npx k6-slack-ms-teams-reporterThe reporter will automatically pick up configurations from reportConfig.json or reportConfig.js.
📝 Example Slack & Teams Reports
📌 Slack Report
📌 Microsoft Teams Report
📌 CI/CD Integration
GitHub Actions
- name: Send K6 Report to Slack
run: npx k6-slack-ms-teams-reporter
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Send K6 Report to Microsoft Teams
run: npx k6-slack-ms-teams-reporter
env:
TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}GitLab CI
stages:
- test
- report
report:
stage: report
script:
- npx k6-slack-ms-teams-reporter
only:
- main🛠 Debugging & Troubleshooting
- Run with verbose logs:
node src/index.js --target slack --report-name k6TestResults --verbose - Check webhook URL is valid
- Ensure
reports/k6TestResults.jsonexists - Check network connectivity & API limits
📜 License
This project is MIT Licensed.
🚀 Developed by @paschal_cheps | Contributions Welcome! 💡
