Skip to content

How to Integrate CucumberJS with TestBeats ​

This guide shows you how to send your CucumberJS test results to Slack, Microsoft Teams, or Google Chat using TestBeats.

What You'll Achieve ​

After following this guide, your CucumberJS BDD tests will automatically send results to your team communication channels, complete with AI-powered failure analysis and detailed reporting.

Prerequisites ​

Before starting, ensure you have:

  • A JavaScript project with CucumberJS tests
  • Node.js and npm/yarn installed
  • TestBeats installed (npx testbeats@latest --version)
  • A webhook URL for your communication platform (Slack, Teams, or Chat)
  • (Optional) TestBeats API key from app.testbeats.com

Step 1: Configure CucumberJS to Generate JSON Reports ​

CucumberJS needs to output test results in JSON format for TestBeats to process.

Option A: Command Line Configuration ​

Run your tests with the JSON formatter:

bash
# Basic JSON output
cucumber-js --format json:results/cucumber-report.json

# Multiple formatters (JSON + console)
cucumber-js --format progress --format json:results/cucumber-report.json

# With specific features
cucumber-js features/login.feature --format json:results/cucumber-report.json

Option B: Configuration File ​

Create a cucumber.json configuration file:

json
{
  "default": {
    "format": [
      "progress",
      "json:results/cucumber-report.json"
    ],
    "require": ["step-definitions/**/*.js"],
    "publishQuiet": true
  }
}

Step 2: Run Your Tests ​

Execute your CucumberJS tests using your preferred method:

bash
# Run all features
cucumber-js --format json:results/cucumber-report.json

# Run specific feature
cucumber-js features/login.feature --format json:results/cucumber-report.json

# Run with tags
cucumber-js --tags "@smoke" --format json:results/cucumber-report.json

This will generate a JSON report file at results/cucumber-report.json.

Step 3: Choose Your Integration Method ​

You have two options to send results to TestBeats:

Option A: Command Line (Quick Setup) ​

For quick testing or simple setups:

bash
npx testbeats@latest publish \
  --api-key '<your-api-key>' \
  --slack '<your-webhook-url>' \
  --cucumber 'results/cucumber-report.json'

For more control and CI/CD integration, create a testbeats.config.json:

json
{
  "api_key": "<your-api-key>",
  "targets": [
    {
      "name": "slack",
      "inputs": {
        "url": "<your-webhook-url>"
      }
    }
  ],
  "results": [
    {
      "type": "cucumber",
      "files": ["results/cucumber-report.json"]
    }
  ]
}

Then run:

bash
npx testbeats@latest publish -c testbeats.config.json

Example Integration ​

For a complete example of integrating CucumberJS with TestBeats, refer to the GitHub repository example.

Next Steps ​

Released under the MIT License.