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 earlier | v4.2.0 and later | |
|---|---|---|
| How to generate | Create a dedicated Node.js script and call report.generate(options) | Run mchr CLI command with a config file |
| Configuration | Passed directly as options to report.generate() | Stored in a config file (JSON, YAML, JS, or TS) |
| Script required | Yes | No |
| CI/CD usage | Run the script with node ./generate-report.js | Run mchr directly |
Before: v4.1.0 and earlier
In the older approach, you had to:
- Install the package locally as a dev dependency.
- Create a dedicated script (e.g.,
generate-report.js) that calledreport.generate(). - Add the script to your
package.jsonand 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:
- Install the package globally (or use
npx). - Create a config file with your reporter options.
- Run
mchrin your terminal or CI pipeline to generate the report.
Step 1: Install globally
npm install multiple-cucumber-html-reporter --globalStep 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:
mchrYou 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
- ✅ Uninstall the locally installed package (if only used for report generation) and install it globally.
- ✅ Delete your old
generate-report.js(or equivalent) script. - ✅ Create a config file (
.multiple-cucumber-html-reporter.jsonor preferred format) with the same options you previously passed toreport.generate(). - ✅ Update your
package.jsonor CI pipeline script to callmchrinstead ofnode ./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