### Install and Verify TestBeats CLI Source: https://docs.testbeats.com/guides/getting-started Installs and verifies the TestBeats CLI tool. Requires Node.js for the recommended method or direct download for systems without Node.js. Outputs the installed version. ```bash npx testbeats --version ``` ```bash # Download TestBeats executable curl https://raw.githubusercontent.com/test-results-reporter/testbeats/main/scripts/download-latest.sh | bash # Verify installation (for Linux) ./testbeats-linux --version # Verify installation (for macOS) ./testbeats-macos --version # Verify installation (for Windows) ./testbeats-win.exe --version ``` -------------------------------- ### Publish Test Results to TestBeats Portal Source: https://docs.testbeats.com/guides/getting-started Publishes JUnit XML test results to the TestBeats Portal using the CLI. Requires an API key and the path to the results file. Outputs the publishing status. ```bash # Using npx (if you have Node.js) npx testbeats publish \ --api-key \ --junit results.xml # OR using direct executable ./testbeats publish \ --api-key \ --junit results.xml ``` -------------------------------- ### Create Sample JUnit XML Test Results Source: https://docs.testbeats.com/guides/getting-started Creates a sample JUnit XML file named 'results.xml'. This file simulates test results, including test suites, test cases, and failures, compatible with most testing frameworks. ```xml AssertionError: Login should have failed with invalid credentials at LoginTest.testInvalidLogin(LoginTest.java:25) ``` -------------------------------- ### Example Configuration: Using launch_id (JSON) Source: https://docs.testbeats.com/references/extensions/report-portal-analysis An example configuration demonstrating how to use the ReportPortal Analysis extension with a specific launch ID. This setup targets Microsoft Teams and includes the necessary ReportPortal credentials and the launch ID for analysis. It also specifies the TestNG results file for processing. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" }, "extensions": [ { "name": "report-portal-analysis", "inputs": { "url": "", "api_key": "", "project": "", "launch_id": "" } } ] } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### Install TestBeats via NPX Source: https://docs.testbeats.com/references/cli Installs and runs the latest version of TestBeats using NPX. This is the recommended installation method for quick access to the CLI. ```bash npx testbeats@latest [command] ``` -------------------------------- ### TestBeats Configuration File Example Source: https://docs.testbeats.com/references/configuration Example of the main TestBeats configuration file (.testbeats.json). It specifies API key, project details, results sources, communication targets, and extensions. ```json { "api_key": "", "project": "my-awesome-project", "run": "Build 123 - main", "results": [ { "type": "junit", "files": ["**/test-results.xml"] } ], "targets": [ { "name": "slack", "condition": "fail", "inputs": { "url": "", "publish": "failure-details" } } ], "extensions": [ { "name": "mentions", "inputs": { "users": ["john.doe@company.com"] } } ] } ``` -------------------------------- ### Install TestBeats via NPM Package Source: https://docs.testbeats.com/references/cli Installs TestBeats globally using NPM, making the 'testbeats' command available system-wide. This allows for direct execution of TestBeats commands after installation. ```bash npm install testbeats -g testbeats [command] ``` -------------------------------- ### Configuration Example: Single Team Channel Source: https://docs.testbeats.com/references/targets/slack Illustrates a configuration file setup for sending failure details to a specific team channel in Slack. It uses a 'fail' condition and customizes the title and failure-only reporting. ```json { "targets": [ { "name": "slack", "condition": "fail", "inputs": { "url": "", "publish": "failure-details", "title": "🚨 Test Failures", "only_failures": true } } ], "results": [ { "type": "testng", "files": [ "path/to/testng-results.xml" ] } ] } ``` -------------------------------- ### Configuration Example: Multiple Environments Source: https://docs.testbeats.com/references/targets/slack Demonstrates a configuration for sending different types of test summaries to multiple Slack channels for staging and production environments. This example shows how to target different webhooks with distinct suffixes and report formats. ```json { "targets": [ { "name": "slack", "inputs": { "url": "", "title_suffix": " - Staging" } }, { "name": "slack", "inputs": { "url": "", "title_suffix": " - Production", "publish": "test-summary-slim" } } ], "results": [ { "type": "testng", "files": [ "path/to/testng-results.xml" ] } ] } ``` -------------------------------- ### Create Local Development .env File Source: https://docs.testbeats.com/references/configuration/env-vars Example .env file for local development setup. Includes API keys, project configuration, webhook URLs, and CI detection overrides for testing without CI/CD platform. ```bash # .env (local development) TEST_BEATS_API_KEY=tb_dev_key_123 TEST_BEATS_PROJECT=my-project-local SLACK_WEBHOOK_URL=https://hooks.slack.com/services/.../dev-channel # Override CI detection for local testing TEST_BEATS_CI_NAME=Local Development TEST_BEATS_CI_USER=developer ``` -------------------------------- ### TestBeats Init Command with Version Option Source: https://docs.testbeats.com/references/cli/init Displays the version of TestBeats installed. This option can be used with the init command to verify the testbeats version before initialization. ```bash npx testbeats@latest init -v ``` -------------------------------- ### Example Configuration: Using launch_name (JSON) Source: https://docs.testbeats.com/references/extensions/report-portal-analysis An example configuration showcasing the ReportPortal Analysis extension with a launch name instead of a launch ID. This approach is useful when the launch ID is not readily available. The configuration targets Microsoft Teams and specifies the ReportPortal details along with the launch name. It also includes the TestNG results file. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" }, "extensions": [ { "name": "report-portal-analysis", "inputs": { "url": "", "api_key": "", "project": "", "launch_name": "" } } ] } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### Install TestBeats Download Executable Source: https://docs.testbeats.com/references/cli Downloads and executes the latest TestBeats script. This method fetches an executable for your operating system, allowing direct command execution. ```bash curl https://raw.githubusercontent.com/test-results-reporter/testbeats/main/scripts/download-latest.sh | bash ./testbeats-[os] [command] ``` -------------------------------- ### Test Configuration with Verbose Output Source: https://docs.testbeats.com/references/targets/slack A command-line example to test the Slack integration configuration with minimal settings. It includes the webhook URL, a sample report path, and the `--verbose` flag to provide detailed output for debugging. ```bash # Test with minimal configuration npx testbeats@latest publish \ --slack '' \ --junit '' \ --verbose ``` -------------------------------- ### Example HTTP Target in TestBeats Configuration Source: https://docs.testbeats.com/references/targets/http This JSON example illustrates how to integrate an HTTP target within a larger TestBeats configuration file. It shows the structure for defining targets, including the HTTP target with its specific inputs, and specifies the types and locations of test results to be processed. ```json { "targets": [ { "name": "http", "condition": "fail", "inputs": { "url": "https://api.example.com/test-results", "headers": { "Authorization": "Bearer your-api-key" } } } ], "results": [ { "type": "testng", "files": [ "path/to/testng-results.xml" ] } ] } ``` -------------------------------- ### Configure Basic CI Info with Slack Target Source: https://docs.testbeats.com/references/extensions/ci-info Example configuration that attaches repository name/link, repository branch name, and build name/link to Slack notifications using the CI-Info extension with minimal configuration. ```json { "targets": [ { "name": "slack", "inputs": { "url": "{SLACK_WEBHOOK_URL}" } } ], "extensions": [ { "name": "ci-info" } ] } ``` -------------------------------- ### Publish Using Configuration File Source: https://docs.testbeats.com/references/cli/publish Executes the publish command using a JSON configuration file. This method is preferred for complex setups with multiple targets, result formats, and extensions. ```bash npx testbeats publish -c testbeats.config.json ``` -------------------------------- ### Generate JUnit XML from Go Tests (Go) Source: https://docs.testbeats.com/guides/frameworks/others Commands to install the 'go-junit-report' tool and execute Go tests, piping the output to generate a JUnit XML file. ```bash # Install go-junit-report go install github.com/jstemmer/go-junit-report/v2@latest # Run tests with JUnit output go test -v ./... | go-junit-report -set-exit-code > test-results/junit.xml ``` -------------------------------- ### Example: Custom Target with File Path (JSON & JS) Source: https://docs.testbeats.com/references/targets/custom Demonstrates how to configure a custom target using a file path to a JavaScript file. The example includes the `config.json` structure and the content of the `custom.js` file. ```json { "reports": [ { "targets": [ { "name": "custom", "inputs": { "load": "./custom.js" } } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ] } ``` ```javascript async function run({ target, result }) { // custom code } module.exports = { run } ``` -------------------------------- ### Install Jest JUnit Reporter (JavaScript) Source: https://docs.testbeats.com/guides/frameworks/others NPM command to install the 'jest-junit' package as a development dependency for Jest. ```bash npm install --save-dev jest-junit ``` -------------------------------- ### Configure InfluxDB Target - Complete Example with Tags Source: https://docs.testbeats.com/references/targets/influx Complete InfluxDB target configuration with custom tags for organizing test results by team and product. Includes target configuration within a targets array along with TestNG result file specifications. ```json { "targets": [ { "name": "influx", "inputs": { "url": "", "db": "TestResults", "tags": { "Team": "QA", "Product": "PactumJS" } } } ], "results": [ { "type": "testng", "files": [ "path/to/testng-results.xml" ] } ] } ``` -------------------------------- ### TestBeats Configuration File Schema Source: https://docs.testbeats.com/references/cli/publish Complete JSON configuration file structure for complex publish setups. Defines API key, communication targets with extensions, and result file patterns. Supports multiple targets, each with optional extensions for enhanced reporting. ```json { "api_key": "api-key", "targets": [ { "name": "slack", "inputs": { "url": "https://hooks.slack.com/..." }, "extensions": [ { "name": "ci-info" }, { "name": "chart-test-summary" } ] } ], "results": [ { "type": "junit", "files": ["test-results/*.xml"] } ] } ``` -------------------------------- ### Programmatic Usage of TestBeats Source: https://docs.testbeats.com/references/cli Demonstrates how to use TestBeats programmatically within a Node.js application. It requires installing the 'testbeats' package and importing the 'publish' and 'defineConfig' functions. ```javascript const { publish, defineConfig } = require('testbeats'); const config = defineConfig({ // configuration }); publish(config); ``` -------------------------------- ### Example: Custom Extension via File Path (JSON) Source: https://docs.testbeats.com/references/extensions/custom This is an example of a TestBeats configuration file that includes a custom extension. The extension is loaded from a local file path './custom.js', demonstrating how to integrate custom logic into the testing workflow. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" }, "extensions": [ { "name": "custom", "inputs": { "load": "./custom.js" } } ] } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### Corresponding .env File for TestBeats Source: https://docs.testbeats.com/references/configuration/env-vars An example .env file containing various environment variables used for TestBeats configuration, including API keys, project settings, notification details, and result paths. ```bash # Portal Configuration TEST_BEATS_API_KEY=api-keyabcdef TEST_BEATS_PROJECT=my-awesome-project TEST_BEATS_RUN=automated-tests # Notification Configuration SLACK_WEBHOOK_URL= SLACK_CHANNEL=#test-alerts TEAMS_WEBHOOK_URL=https://outlook.office.com/webhook/... # Test Results Configuration JUNIT_RESULTS_PATH=test-results/*.xml # CI/CD Override (optional) TEST_BEATS_CI_NAME=Custom CI TEST_BEATS_CI_REPOSITORY_NAME=my-org/my-project ``` -------------------------------- ### Basic Metadata with Slack Notification Source: https://docs.testbeats.com/references/extensions/metadata Complete example showing how to configure metadata extension with Slack target and TestNG results. Demonstrates including simple key-value metadata like browser version and environment variables in test notifications. ```json { "targets": [ { "name": "slack", "inputs": { "url": "{SLACK_WEBHOOK_URL}" } } ], "extensions": [ { "name": "metadata", "inputs": { "data": [ { "key": "Browser", "value": "Chrome 120.0.6099.109" }, { "key": "Environment", "value": "{ENVIRONMENT}" } ] } } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### Example: ReportPortal History with Launch Name and Depth Source: https://docs.testbeats.com/references/extensions/report-portal-history This example shows the ReportPortal History extension configuration using a launch name and specifying a history depth of 10. This allows fetching the latest 10 runs associated with a given launch name for analysis. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" }, "extensions": [ { "name": "report-portal-history", "inputs": { "url": "", "api_key": "", "project": "", "launch_name": "", "history_depth": 10 } } ] } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### Create .env File for TestBeats Configuration Source: https://docs.testbeats.com/references/configuration/env-vars Example .env file for TestBeats containing API keys, project configuration, and webhook URLs. This file must be located in the same directory where TestBeats is executed and will be automatically loaded. ```bash # TestBeats Portal Configuration TEST_BEATS_API_KEY=api-keyabcdef TEST_BEATS_PROJECT=my-project TEST_BEATS_RUN=nightly-tests # Notification Webhooks SLACK_WEBHOOK_URL= TEAMS_WEBHOOK_URL=https://outlook.office.com/webhook/... # CI/CD Overrides TEST_BEATS_CI_NAME=GitHub Actions TEST_BEATS_CI_REPOSITORY_NAME=my-org/my-repo ``` -------------------------------- ### Publish Test Results using TestBeats Publish GitHub Action Source: https://docs.testbeats.com/guides/ci-cd/github-actions This workflow demonstrates using the `test-results-reporter/publish@v1` GitHub Action to publish test results. It includes steps for checking out code, installing dependencies, running tests, and then publishing the results using the action. A TestBeats configuration file (`.testbeats.json`) is specified. ```yaml # .github/workflows/testbeats.yml # This workflow will publish test results to slack name: Test on: pull_request: branches: - main jobs: publish: runs-on: ubuntu-latest steps: - name: Checkout id: checkout uses: actions/checkout@v4 - name: Install Dependencies id: npm-ci run: npm ci - name: Test id: npm-ci-test run: npm run test - name: TestBeats Publish uses: test-results-reporter/publish@v1 with: config: .testbeats.json # TestBeats configuration file path ``` -------------------------------- ### Targets Configuration - Slack Notification Source: https://docs.testbeats.com/references/configuration Example configuration for a communication target, specifically for Slack. It defines the target name, enabling status, notification condition, and input parameters like the webhook URL and publish content. ```json { "name": "slack", "enable": true, "condition": "fail", "inputs": { "url": "https://hooks.slack.com/services/...", "publish": "test-summary" } } ``` -------------------------------- ### Configure Error Clusters (JSON) Source: https://docs.testbeats.com/guides/portal/error-clusters Example JSON configuration for TestBeats, showing how to enable/disable error clusters and configure targets and results. The 'show_error_clusters' key controls the feature's visibility. ```json { "api_key": "", "show_error_clusters": false, "targets": [ { "name": "slack", "inputs": { "url": "" } } ], "results": [ { "type": "testng", "files": [ "path/to/testng-results.xml" ] } ] } ``` -------------------------------- ### Sample Google Chat Target Configuration - JSON Source: https://docs.testbeats.com/references/targets/chat Provides a complete sample configuration file demonstrating how to integrate Google Chat as a target within a broader reporting setup. It shows how to specify the webhook URL, the type of report to publish ('test-summary-slim'), and links it to test results. ```json { "targets": [ { "name": "chat", "inputs": { "url": "", "publish": "test-summary-slim" } } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### TestBeats Configuration with Environment Variables Source: https://docs.testbeats.com/references/configuration/env-vars Example of a complete TestBeats JSON configuration file that utilizes environment variables for API keys, project details, notifications, and results paths. ```json { "api_key": "{TEST_BEATS_API_KEY}", "project": "{TEST_BEATS_PROJECT}", "run": "{TEST_BEATS_RUN}", "targets": [ { "name": "slack", "condition": "fail", "inputs": { "url": "{SLACK_WEBHOOK_URL}", "channel": "{SLACK_CHANNEL}" } }, { "name": "teams", "condition": "pass-fail", "inputs": { "url": "{TEAMS_WEBHOOK_URL}" } } ], "results": [ { "type": "junit", "files": ["{JUNIT_RESULTS_PATH}"] } ], "extensions": [ { "name": "ci-info" } ] } ``` -------------------------------- ### Custom QuickChart URL Configuration for TestBeats Source: https://docs.testbeats.com/references/extensions/chart-test-summary Demonstrates how to configure TestBeats to use a custom or self-hosted QuickChart instance for the test summary extension. This example sets up a 'slack' target and specifies a custom URL for the QuickChart service within the extension's inputs. ```json { "targets": [ { "name": "slack", "inputs": { "url": "{SLACK_WEBHOOK_URL}" } } ], "extensions": [ { "name": "quick-chart-test-summary", "inputs": { "url": "https://charts.your-company.com" } } ] } ``` -------------------------------- ### Dynamic JavaScript Expression Condition with Environment Variables Source: https://docs.testbeats.com/references/configuration Configure a condition using JavaScript expressions that evaluate environment variables. This example enables a Teams extension with mentions when the GIT_BRANCH equals 'main'. The condition is evaluated at runtime and must return a boolean value. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" }, "extensions": [ { "name": "mentions", "condition": "{GIT_BRANCH} === 'main'", "inputs": { "users": [ { "name": "Jon", "teams_upn": "jon@microsift.com" } ] } } ] } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### Configure Percy Analysis with Teams Webhook - Project Name Source: https://docs.testbeats.com/references/extensions/percy-analysis Complete example configuration for Percy Analysis extension integrated with Microsoft Teams reporting, using project_name for build identification. Includes TestNG results parsing with configurable snapshots approval tracking. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" }, "extensions": [ { "name": "percy-analysis", "inputs": { "token": "", "project_name": "" } } ] } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### Command-Line Override with TestBeats CLI Source: https://docs.testbeats.com/references/configuration Override configuration file settings using command-line arguments. This example demonstrates how the --teams flag overrides the Slack configuration specified in config.json, allowing dynamic target selection at runtime. ```bash # Configuration file specifies Slack, but command overrides with Teams npx testbeats publish -c config.json --teams $TEAMS_WEBHOOK ``` -------------------------------- ### TestBeats Init Command with Help Option Source: https://docs.testbeats.com/references/cli/init Displays help information for the init command, including available options and usage details. ```bash npx testbeats@latest init -h ``` -------------------------------- ### Initialize TestBeats Configuration with NPX Source: https://docs.testbeats.com/references/cli/init Initializes a new TestBeats configuration file in the project directory. This command creates a .testbeats.json file with default settings that can be customized. It is the primary method for setting up TestBeats in a new project. ```bash npx testbeats@latest init ``` -------------------------------- ### Install Mocha JUnit Reporter Source: https://docs.testbeats.com/guides/frameworks/mocha Installs the mocha-junit-reporter package as a development dependency. This reporter is needed to generate JUnit XML reports for TestBeats. ```bash npm install mocha-junit-reporter --save-dev ``` -------------------------------- ### Install Cucumber Reporter for WebdriverIO Source: https://docs.testbeats.com/guides/frameworks/webdriverio Installs the Cucumber JSON reporter for WebdriverIO. This reporter is used when integrating with Cucumber for BDD style tests, generating JSON reports that TestBeats can parse. ```bash npm install --save-dev @wdio/cucumberjs-json-reporter ``` -------------------------------- ### Install JUnit Reporter for WebdriverIO Source: https://docs.testbeats.com/guides/frameworks/webdriverio Installs the necessary JUnit reporter package for WebdriverIO using npm. This allows WebdriverIO to generate test results in JUnit XML format, which TestBeats can process. ```bash npm install --save-dev @wdio/junit-reporter ``` -------------------------------- ### Example: ReportPortal History with Launch ID Source: https://docs.testbeats.com/references/extensions/report-portal-history This example demonstrates how to configure the ReportPortal History extension within a 'teams' target. It specifies the ReportPortal connection details using a launch ID and indicates that test results are in 'testng' format. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" }, "extensions": [ { "name": "report-portal-history", "inputs": { "url": "", "api_key": "", "project": "", "launch_id": "" } } ] } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ``` -------------------------------- ### TestBeats Publish Command Basic Syntax Source: https://docs.testbeats.com/references/cli/publish Basic command syntax for invoking the TestBeats publish command. Supports both direct execution and configuration file modes. Use the first form for CLI-based options or the second form to reference a configuration file. ```bash npx testbeats publish [options] npx testbeats publish -c ``` -------------------------------- ### Complete TestBeats Configuration with Extensions Source: https://docs.testbeats.com/references/configuration Comprehensive TestBeats configuration demonstrating multiple targets with conditions, environment variable interpolation, custom titles, mentions extensions, and hyperlink extensions. Includes API key, project metadata, and multiple result file patterns. ```json { "api_key": "${TESTBEATS_API_KEY}", "project": "${CI_PROJECT_NAME}", "run": "Build ${CI_PIPELINE_ID} - ${CI_COMMIT_REF_NAME}", "targets": [ { "name": "slack", "condition": "fail", "inputs": { "url": "${SLACK_WEBHOOK_URL}", "publish": "failure-details", "title": "🚨 Test Failures", "title_link": "${CI_PIPELINE_URL}", "only_failures": true } }, { "name": "teams", "inputs": { "url": "${TEAMS_WEBHOOK_URL}", "publish": "test-summary", "title": "📊 Test Results" } } ], "results": [ { "type": "junit", "files": ["**/test-results.xml", "**/junit.xml"] } ], "extensions": [ { "name": "mentions", "condition": "fail", "inputs": { "users": ["team-lead@company.com"], "teams": ["qa-team"] } }, { "name": "hyperlinks", "inputs": { "links": [ { "text": "View Build", "url": "${CI_PIPELINE_URL}" } ] } } ] } ``` -------------------------------- ### Example Usage: Delay and Slack Notification - JSON Source: https://docs.testbeats.com/references/targets/delay This example demonstrates how to use the 'delay' target in conjunction with other targets, like sending a Slack notification. It shows a sequence where execution is paused for 10 seconds before a Slack message is published. ```json { "targets": [ { "name": "delay", "inputs": { "seconds": 10 } }, { "name": "slack", "inputs": { "url": "", "publish": "test-summary-slim" } } ], "results": [ { "type": "testng", "files": [ "path/to/testng-results.xml" ] } ] } ``` -------------------------------- ### Add Static Hyperlinks with Slack Integration Source: https://docs.testbeats.com/references/extensions/hyperlinks Create static links to common CI/CD resources and integrate with Slack webhook. Demonstrates how to configure multiple links with environment variable substitution for build IDs and other dynamic parameters. ```json { "targets": [ { "name": "slack", "inputs": { "url": "{SLACK_WEBHOOK_URL}" } } ], "extensions": [ { "name": "hyperlinks", "inputs": { "links": [ { "text": "Build Logs", "url": "https://ci.example.com/logs/{BUILD_ID}" }, { "text": "Test Report", "url": "https://reports.example.com/{BUILD_ID}" } ] } } ] } ``` -------------------------------- ### Export Environment Variable Source: https://docs.testbeats.com/references/configuration/env-vars Example of how to export an environment variable, such as SLACK_WEBHOOK_URL, which is required for TestBeats notifications. ```bash export SLACK_WEBHOOK_URL="https://hooks.slack.com/..." ``` -------------------------------- ### Configure Basic GitHub Target Source: https://docs.testbeats.com/references/targets/github Sets up a minimal GitHub target configuration with only the required authentication token. This configuration enables publishing test results to GitHub pull requests using the provided token. ```json { "targets": [ { "name": "github", "inputs": { "token": "your-github-token" } } ] } ``` -------------------------------- ### Run TestNG Tests with Gradle Source: https://docs.testbeats.com/guides/frameworks/testng Commands to execute TestNG tests using Gradle. Provides options to run all tests or to run tests for a specific class. ```bash # Run all tests ./gradlew test # Run specific test class ./gradlew test --tests com.example.tests.LoginTest ``` -------------------------------- ### Configure Cucumber Reporter in wdio.conf.js Source: https://docs.testbeats.com/guides/frameworks/webdriverio Configures WebdriverIO to use the Cucumber JSON reporter. This setup is for projects using Cucumber, specifying the output directory for the generated JSON test reports. ```javascript // wdio.conf.js export const config = { framework: 'cucumber', reporters: [ 'spec', ['cucumberjs-json', { outputDir: './results' }] ] } ``` -------------------------------- ### Publish with Extensions and Enhancements Source: https://docs.testbeats.com/references/cli/publish Publishes test results with additional features including CI/CD environment information and visual test summary charts. Extensions enhance the published report with contextual metadata and visual elements for better insights. ```bash npx testbeats publish \ --ci-info \ --chart-test-summary \ --slack "https://hooks.slack.com/..." \ --junit "test-results/*.xml" ``` -------------------------------- ### Configure CI Info Extension - Basic Configuration Source: https://docs.testbeats.com/references/extensions/ci-info Basic syntax for configuring the CI-Info extension with standard options to display repository information, branch name, and build details. This configuration serves as the foundation for attaching CI/CD pipeline metadata to notifications. ```json { "name": "ci-info", "inputs": { "show_repository": false, "show_repository_branch": true, "show_build": true, "data": [ { "key": "Download Logs", "value": "", "type": "hyperlink" } ] } } ``` -------------------------------- ### JMeter JTL File Example Source: https://docs.testbeats.com/guides/frameworks/jmeter This is a sample JSON configuration for TestBeats, specifically for processing JMeter JTL result files. It outlines the structure for specifying the JTL file and setting up basic validation. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" } } ], "results": [ { "type": "jmeter", "files": ["path/to/result.jtl"] } ] } ``` -------------------------------- ### Default Configuration for TestBeats with QuickChart Summary Source: https://docs.testbeats.com/references/extensions/chart-test-summary Illustrates the default configuration for TestBeats, enabling the 'quick-chart-test-summary' extension. It shows how to set up a 'teams' target and includes the extension without custom QuickChart URL inputs, relying on the default service. ```json { "targets": [ { "name": "teams", "inputs": { "url": "{TEAMS_WEBHOOK_URL}" } } ], "extensions": [ { "name": "quick-chart-test-summary" } ] } ``` -------------------------------- ### Configure Complete GitHub Target with All Options Source: https://docs.testbeats.com/references/targets/github Provides a comprehensive GitHub target configuration with repository details, custom titles, suite inclusion settings, and failure details. Includes TestNG result file configuration for publishing test results with maximum customization. ```json { "targets": [ { "name": "github", "inputs": { "token": "your-github-token", "owner": "your-org", "repo": "your-repo", "pull_number": "123", "title": "Custom Test Title", "title_suffix": "- Build #456", "title_link": "https://your-ci-system.com/build/456", "include_suites": true, "include_failure_details": true, "only_failures": false, "max_suites": 10, "duration": "long", "publish": "test-summary" } } ], "results": [ { "type": "testng", "files": [ "path/to/testng-results.xml" ] } ] } ``` -------------------------------- ### JMeter Configuration Mode Setup Source: https://docs.testbeats.com/guides/frameworks/jmeter This JSON configuration defines the JMeter test result format for TestBeats. It specifies the file paths for the JMeter results and sets performance thresholds for metrics like 'Duration'. ```json { "type": "jmeter", "files": ["tests/data/jmeter/sample.csv"], "thresholds": [ { "metric": "Duration", "checks": ["avg<5000"] } ] } ``` -------------------------------- ### Configure Basic Metadata Extension Source: https://docs.testbeats.com/references/extensions/metadata Defines a basic metadata configuration object with key-value pairs and optional hyperlinks. Supports displaying browser information, resolution, build logs, and screenshots with optional conditional rendering based on test outcomes. ```json { "name": "metadata", "inputs": { "data": [ { "key": "Browser", "value": "chrome" }, { "value": "1920 x 1080" }, { "key": "Build Logs", "value": "", "type": "hyperlink" }, { "key": "Screenshots", "value": "", "type": "hyperlink", "condition": "fail" } ] } } ``` -------------------------------- ### Basic Configuration for QuickChart Test Summary Extension Source: https://docs.testbeats.com/references/extensions/chart-test-summary Defines the basic JSON structure for configuring the 'quick-chart-test-summary' extension. It specifies the extension name and its inputs, including an optional URL for the QuickChart service. ```json { "name": "quick-chart-test-summary", "inputs": { "url": "" } } ``` -------------------------------- ### Publish Test Results to Slack (Basic CLI) Source: https://docs.testbeats.com/references/targets/slack Command-line interface command to publish test results to Slack using a webhook URL and JUnit report path. This is a basic usage example for direct execution. ```bash npx testbeats@latest publish \ --slack '' \ --junit '' ``` -------------------------------- ### Run TestNG Tests with Maven Source: https://docs.testbeats.com/guides/frameworks/testng Commands to execute TestNG tests using Maven. Includes options to run all tests, a specific test suite defined by an XML file, or tests belonging to specific groups. ```bash # Run all tests mvn clean test # Run specific test suite mvn clean test -DsuiteXmlFile=src/test/resources/testng.xml # Run with specific groups mvn clean test -Dgroups=smoke,regression ``` -------------------------------- ### Example: Custom Target with Inline Function (JSON) Source: https://docs.testbeats.com/references/targets/custom Shows how to configure a custom target directly using an inline asynchronous JavaScript function within the JSON configuration. This allows for immediate execution of custom logic. ```json { "reports": [ { "targets": [ { "name": "custom", "inputs": { "load": async ({ result }) => { } } } ], "results": [ { "type": "testng", "files": ["path/to/testng-results.xml"] } ] } ] } ``` -------------------------------- ### Run Cypress Tests Source: https://docs.testbeats.com/guides/frameworks/cypress Executes the Cypress test suite using the standard npm command. This generates JUnit XML files in the configured results directory that can be processed by TestBeats. ```bash npx cypress run ``` -------------------------------- ### Publish JUnit XML via Command Line to Slack Source: https://docs.testbeats.com/guides/frameworks/junit This command-line interface (CLI) command publishes JUnit XML test results to a specified Slack webhook URL using TestBeats. It requires your TestBeats API key and the Slack webhook URL. The `--junit` flag specifies the pattern for locating the XML files. ```bash npx testbeats@latest publish \ --api-key '' \ --slack '' \ --junit 'results/junit-*.xml' ``` -------------------------------- ### Publish test results to Slack using command line Source: https://docs.testbeats.com/references/targets Send JUnit test reports to Slack channels via webhook URL using the TestBeats CLI. Supports simple single-target setup for quick integration with Slack messaging channels. ```bash npx testbeats@latest publish --slack '' --junit '' ``` -------------------------------- ### Configuration File: Single Team Channel (JSON) Source: https://docs.testbeats.com/references/targets/teams This JSON configuration example sets up TestBeats to send failure details to a specific Microsoft Teams channel. It uses a 'fail' condition, custom title, and requests full message width. ```json { "targets": [ { "name": "teams", "condition": "fail", "inputs": { "url": "", "publish": "failure-details", "title": "🚨 Test Failures", "only_failures": true, "width": "Full" } } ], "results": [ { "type": "testng", "files": [ "path/to/testng-results.xml" ] } ] } ``` -------------------------------- ### Publish Results with GitHub Actions Environment Variable Source: https://docs.testbeats.com/references/targets/github Demonstrates publishing test results using GitHub Actions with the automatically-provided GITHUB_TOKEN environment variable. The command line passes the token and JUnit results file path to the publish command. ```yaml - name: Publish Results run: npx testbeats publish --github {GITHUB_TOKEN} --junit 'results/junit.xml' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -------------------------------- ### Async Function Condition Evaluating Test Results Source: https://docs.testbeats.com/references/configuration Define a condition as an asynchronous function that receives target and result context objects. This example triggers a Teams notification only when the number of failed tests exceeds 2. The function must return a boolean value. ```javascript const config = { targets: [ { name: "teams", condition: async ({ target, result }) => { return result.failed > 2; }, inputs: { url: "", }, }, ], results: [ { type: "testng", files: ["path/to/testng-results.xml"], }, ], }; ``` -------------------------------- ### Configure TestBeats Extensions in JSON Source: https://docs.testbeats.com/references/extensions This JSON configuration shows how to enable and configure TestBeats extensions, such as 'ci-info' and 'mentions', within the `testbeats.json` file. It demonstrates setting up notification targets like Slack and defining user mentions with their respective identifiers. ```json { "targets": [ { "name": "slack", "inputs": { "url": "{SLACK_WEBHOOK_URL}" } } ], "extensions": [ { "name": "ci-info" }, { "name": "mentions", "inputs": { "users": [ { "name": "Jon", "teams_upn": "jon@microsoft.com" }, { "name": "qa-team", "slack_gid": "UXXXXXXX" } ] } } ] } ``` -------------------------------- ### Publish Test Results to Slack (CLI with Options) Source: https://docs.testbeats.com/references/targets/slack Advanced command-line usage for publishing test results to Slack, including additional options like an API key. This allows for more customized or authenticated interactions with the publishing service. ```bash npx testbeats@latest publish \ --slack '' \ --junit '' \ --api-key '' ``` -------------------------------- ### Configure Custom Links in CI Info Extension Source: https://docs.testbeats.com/references/extensions/ci-info Example configuration that adds custom hyperlinks for downloading logs and artifacts to Microsoft Teams notifications. Demonstrates how to attach additional CI/CD resources using the data property with URL templates and BUILD_ID variables. ```json { "targets": [ { "name": "teams", "inputs": { "url": "{TEAMS_WEBHOOK_URL}" } } ], "extensions": [ { "name": "ci-info", "inputs": { "data": [ { "key": "Download Logs", "value": "https://ci.example.com/logs/{BUILD_ID}", "type": "hyperlink" }, { "key": "Artifacts", "value": "https://ci.example.com/artifacts/{BUILD_ID}", "type": "hyperlink" } ] } } ] } ``` -------------------------------- ### Publish with TestBeats Portal Integration Source: https://docs.testbeats.com/references/cli/publish Publishes test results to Slack while integrating with TestBeats portal using an API key. The API key enables additional portal features and project organization. Requires a valid TestBeats API key. ```bash npx testbeats publish \ --api-key "api-key" \ --slack "https://hooks.slack.com/..." \ --junit "test-results/*.xml" ``` -------------------------------- ### Configure Conditional Display in CI Info Extension Source: https://docs.testbeats.com/references/extensions/ci-info Example configuration that shows different information based on test results using the condition property. Displays failure reports on test failures and coverage reports on test passes, enabling context-aware notification content. ```json { "name": "ci-info", "inputs": { "show_repository": true, "show_build": true, "data": [ { "key": "Failed Tests Report", "value": "https://reports.example.com/failures/{BUILD_ID}", "type": "hyperlink", "condition": "fail" }, { "key": "Coverage Report", "value": "https://coverage.example.com/{BUILD_ID}", "type": "hyperlink", "condition": "pass" } ] } } ``` -------------------------------- ### Run WebdriverIO Tests via CLI Source: https://docs.testbeats.com/guides/frameworks/webdriverio Commands to execute WebdriverIO tests using the CLI. It shows how to run all tests or a specific suite, generating the necessary reports for TestBeats. ```bash # Run all tests npx wdio run wdio.conf.js # Run specific suite npx wdio run wdio.conf.js --suite login ``` -------------------------------- ### Configure TestBeats MCP Server for Claude Desktop Source: https://docs.testbeats.com/guides/portal/mcp JSON configuration for setting up TestBeats MCP integration in Claude Desktop using the mcp-remote package via npx. This configuration should be added to the Claude Desktop configuration file at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%/Claude/claude_desktop_config.json on Windows, or ~/.config/Claude/claude_desktop_config.json on Linux. ```json { "mcpServers": { "testbeats": { "command": "npx", "args": [ "-y", "mcp-remote@latest", "https://app.testbeats.com/api/core/v1/mcp", "--header", "x-personal-access-token: " ] } } } ``` -------------------------------- ### JMeter Aggregate CSV with Thresholds Example Source: https://docs.testbeats.com/guides/frameworks/jmeter This JSON configuration demonstrates how to use TestBeats with JMeter aggregate CSV files, including advanced threshold settings. It allows for defining pass/fail criteria based on metrics like 'Samples' and 'Duration' with specific scopes and transactions. ```json { "targets": [ { "name": "teams", "inputs": { "url": "" } } ], "results": [ { "type": "jmeter", "files": ["path/to/aggregate.csv"], "thresholds": [ { "metric": "Samples", "checks": ["sum>1"] }, { "metric": "Duration", "checks": [ "p95<2000", "avg<2500" ], "scope": "TRANSACTION", "transactions": [""] } ] } ] } ``` -------------------------------- ### TestBeats Configuration File Setup Source: https://docs.testbeats.com/guides/frameworks/playwright Create a testbeats.config.json file to configure TestBeats for production use and CI/CD integration. This JSON configuration specifies API credentials, target communication platforms (Slack, Teams, Chat), and result file locations for automated test reporting. ```json { "api_key": "", "targets": [ { "name": "slack", "inputs": { "url": "" } } ], "results": [ { "type": "junit", "files": ["test-results/junit.xml"] } ] } ```