Test Results Reporter
website·Indexed 29 days ago
https://test-results-reporter.github.io/A library for publishing automation test results to communication platforms such as Slack, Microsoft Teams, and Google Chat. It supports various testing frameworks like Cucumber and Mocha, integrates with CI/CD tools including GitHub Actions and Azure Pipelines, and provides extensions for ReportPortal, Percy, and QuickChart.
What's inside Test Results Reporter
- Test Results Reporter is a library used as an alerting tool to forward automation test results from CI/CD environments to communication platforms. It provides immediate visibility into test success or failure to facilitate quicker issue resolution.
Integrate ReportPortal analysis into test reports
Thereport-portal-analysisextension allows you to include ReportPortal failure analysis (associating failures with product bugs, automation issues, or system issues) in notifications sent to Microsoft Teams or Slack. By default, this extension triggers on theendhook when the test condition isfail.Add a radial gauge test summary using QuickChart
The
quick-chart-test-summaryextension generates a radial gauge image representing the total pass percentage of test results. It is designed for use with Teams and Slack targets. Note that this extension is not supported for the Google Chat target.Default Behavior:
- Hook:
post-main - Condition:
passOrFail
- Hook:
Integrate QuickChart test summary radial gauge into reports
The
quick-chart-test-summaryextension generates a radial gauge image representing the total pass percentage of tests and attaches it to the report.Defaults:
- Hook:
post-main - Condition:
passOrFail
Limitation: This extension is not supported for the Google Chat target.
- Hook:
Use Mocha with the JSON reporter for test results
To use the default Mocha JSON reporter, run tests with the--reporter jsonflag. In the tool's configuration file, specify the result type asmochaand provide the path to the generated JSON result file.mocha tests --reporter json{ "targets": [ { "name": "slack", "inputs": { "url": "<incoming-webhook-url>" } } ], "results": [ { "type": "mocha", "files": ["path/to/result.json"] } ] }Publish Mocha test results using the JSON reporter
To use the default Mocha JSON reporter, run your tests with the--reporter jsonflag. In the tool's configuration file, set the resulttypetomochaand provide the path to the generated JSON result file.mocha tests --reporter json{ "targets": [ { "name": "slack", "inputs": { "url": "<incoming-webhook-url>" } } ], "results": [ { "type": "mocha", "files": ["path/to/result.json"] } ] }Set up a TestBeats account and API key
To begin using TestBeats, sign up with a work email at app.testbeats.com. After signing up, create a new organization to generate the API key required for reporting. Note that other individuals within the same organization sharing the same email domain will automatically have access to the test results.Integrate Percy Analysis with a Teams report target
This example demonstrates how to add thepercy-analysisextension to a Teams notification target. This configuration will send Percy snapshot status (approved/pending) along with the test results from a TestNG XML file to a specified Microsoft Teams webhook.{ "targets": [ { "name": "teams", "inputs": { "url": "<teams-incoming-webhook-url>" }, "extensions": [ { "name": "percy-analysis", "inputs": { "token": "<api-token>", "project_name": "<project-name>" } } ] } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] }Implement a custom target using a separate JavaScript file
To send test results to a custom target using an external file, set the targetnametocustomand provide the path to the JavaScript file in theloadinput. The external file must export an asynchronousrunfunction that receives thetargetandresultobjects.// custom.js async function run({ target, result }) { // custom code to handle results } module.exports = { run };Choose a Slack report type
Depending on the level of detail needed, you can specify one of three report types using the
publishoption:test-summary: Includes test title, total duration, and success percentage. If multiple suites exist, it displays these details per suite.test-summary-slim: Includes only the test title, total duration, and success percentage, ignoring individual test suites. Recommended for keeping primary channels clean.failure-details: Lists the names of failed test cases along with their specific failure reasons.
Implement a custom extension using an inline function
Custom extensions can be defined directly within a JavaScript configuration file by passing an asynchronous function to theloadinput of thecustomextension.module.exports = { targets: [ { name: "teams", inputs: { url: "<some-url>", }, extensions: [ { name: "custom", inputs: { load: async ({ result }) => { // custom logic here }, }, }, ], }, ], results: [ { type: "testng", files: ["path/to/testng-results.xml"], }, ], };Use Mocha with the jUnit reporter for test results
To use the jUnit reporter with Mocha, install themocha-junit-reporterpackage and run tests using themocha-junit-reporterflag. In the tool's configuration file, specify the result type asjunitand provide the path to the generated XML result file.npm install mocha-junit-reporter --save-dev mocha test --reporter mocha-junit-reporter{ "targets": [ { "name": "chat", "inputs": { "url": "<incoming-webhook-url>" } } ], "results": [ { "type": "junit", "files": ["path/to/results.xml"] } ] }