multipleCucumberHTMLreporter

Usage

Detailed instructions on how to use Multiple Cucumber HTML Reporter with different versions of CucumberJS.

Multiple Cucumber HTML Reporter can be run in two primary ways: using a command line tool or programmatically.

Generate report with Command Line Tool

Once you have installed the command line tool properly and the configuration file is setup as per your requirements, then you can generate the report by running the following command on your terminal:

mchr

Generate report programmatically

Basic Usage

To generate a report, use the following code structure:

const report = require("multiple-cucumber-html-reporter");

report.generate({
  jsonDir: "./path-to-your-json-output/",
  reportPath: "./path-where-the-report-needs-to-be/",
  metadata: {
    browser: {
      name: "chrome",
      version: "60",
    },
    device: "Local test machine",
    executionPlatform: 'local',
    platform: {
      name: "ubuntu",
      version: "16.04",
    },
  },
  customData: {
    projectName: 'WebDriverIO sample project',
    release: '1.2.0',
    testCycle: 'Cycle 1',
    buildNumber: 'Build 1',
    environment: 'production',
    ciPipeline: 'GitHub Actions',
  },
});

Integration with Cucumber Versions

The way you execute the report depends on which version of CucumberJS you are using:

CucumberJS 2.x and Lower

You can integrate the reporter directly into your AfterFeatures hook:

const report = require("multiple-cucumber-html-reporter");

// Add this into your AfterFeatures-hook
report.generate({
  // ... configuration ...
});

CucumberJS 3.x and 4.x

Since AfterFeatures hook is no longer supported in newer versions, you must run the reporter as a separate node executable after the cucumber-js process finishes.

Run your tests

Ensure your tests generate JSON results correctly.

Create a separate generate script

Create a file (e.g., generate-report.js) with the reporting logic.

Execute the script

Update your package.json scripts:

{
  "scripts": {
    "test": "cucumber-js -f json:./reports/report.json",
    "generate-report": "node ./generate-report.js"
  }
}

Important

When generating JSON files with Cucumber, ensure each file has a UNIQUE name (e.g., use a timestamp). If you don't, Cucumber may overwrite your results.

Last updated on

On this page