multipleCucumberHTMLreporter

Migrate to v4.2.0

Migrate to the latest v4.2.0 from v4.1.0 or earlier.

What changed in v4.2.0?

Starting from v4.2.0, the Multiple Cucumber HTML Reporter introduces a dedicated CLI tool (mchr) that replaces the need for creating a separate report generation script.

v4.1.0 and earlierv4.2.0 and later
How to generateCreate a dedicated Node.js script and call report.generate(options)Run mchr CLI command with a config file
ConfigurationPassed directly as options to report.generate()Stored in a config file (JSON, YAML, JS, or TS)
Script requiredYesNo
CI/CD usageRun the script with node ./generate-report.jsRun mchr directly

Before: v4.1.0 and earlier

In the older approach, you had to:

  1. Install the package locally as a dev dependency.
  2. Create a dedicated script (e.g., generate-report.js) that called report.generate().
  3. Add the script to your package.json and run it after your tests.

Example: generate-report.js

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

report.generate({
  jsonDir: './.run/reports/json/',
  reportPath: './.run/html-report/',
  openReportInBrowser: true,
  useCDN: true,
  pageTitle: 'My Project Report',
  reportName: 'My Project',
  displayDuration: true,
  displayReportTime: true,
  customData: {
    projectName: 'My Project',
    release: '1.2.0',
    testCycle: process.env.GITHUB_RUN_ID || 'Cycle 1',
    buildNumber: process.env.GITHUB_RUN_NUMBER || 'Build 1',
    environment: 'production',
    ciPipeline: 'GitHub Actions',
  },
});

Example: package.json scripts

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

After: v4.2.0 and later

In the new approach, you no longer need a dedicated script. Instead:

  1. Install the package globally (or use npx).
  2. Create a config file with your reporter options.
  3. Run mchr in your terminal or CI pipeline to generate the report.

Step 1: Install globally

npm install multiple-cucumber-html-reporter --global

Step 2: Create a config file

Replace the contents of your old generate-report.js with a config file in the root of your project. The CLI supports JSON, YAML, JavaScript, and TypeScript formats.

{
  "jsonDir": "./.run/reports/json/",
  "reportPath": "./.run/html-report/",
  "openReportInBrowser": true,
  "useCDN": true,
  "pageTitle": "My Project Report",
  "reportName": "My Project",
  "displayDuration": true,
  "displayReportTime": true,
  "customData": {
    "projectName": "My Project",
    "release": "1.2.0",
    "testCycle": "${GITHUB_RUN_ID:'Cycle 1'}",
    "buildNumber": "${GITHUB_RUN_NUMBER:'Build 1'}",
    "environment": "production",
    "ciPipeline": "GitHub Actions"
  }
}

Tip

You can also run mchr for the first time to launch an interactive onboarding wizard that will generate the config file for you automatically.

Step 3: Generate the report

After setting up the config file, simply run the following command after your tests have completed:

mchr

You can now remove your old generate-report.js script and the corresponding generate-report entry from your package.json.

Updated package.json scripts

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

Summary of migration steps

  1. Uninstall the locally installed package (if only used for report generation) and install it globally.
  2. Delete your old generate-report.js (or equivalent) script.
  3. Create a config file (.multiple-cucumber-html-reporter.json or preferred format) with the same options you previously passed to report.generate().
  4. Update your package.json or CI pipeline script to call mchr instead of node ./generate-report.js.

Note

The programmatic API (report.generate()) is still supported for users who prefer it. See the Usage page for details.

Important

When running in a CI environment, make sure the config file is present in the directory where mchr is executed. The interactive onboarding wizard is automatically skipped on CI, and the CLI will error out if no config file is found.

Last updated on

On this page