What is cucumber-html-reporter?
The cucumber-html-reporter npm package is used to generate HTML reports for Cucumber test results. It provides a way to visualize the results of your Cucumber tests in a more readable and user-friendly format.
What are cucumber-html-reporter's main functionalities?
Generate HTML Report
This feature allows you to generate an HTML report from a Cucumber JSON report. The options object specifies the theme, input JSON file, output HTML file, and additional metadata for the report.
const reporter = require('cucumber-html-reporter');
const options = {
theme: 'bootstrap',
jsonFile: 'cucumber_report.json',
output: 'cucumber_report.html',
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
'App Version': '0.3.2',
'Test Environment': 'STAGING',
'Browser': 'Chrome 54.0.2840.98',
'Platform': 'Windows 10',
'Parallel': 'Scenarios',
'Executed': 'Remote'
}
};
reporter.generate(options);
Custom Metadata
This feature allows you to add custom metadata to your HTML report. The metadata can include information such as the app version, test environment, browser, platform, and execution details.
const reporter = require('cucumber-html-reporter');
const options = {
theme: 'bootstrap',
jsonFile: 'cucumber_report.json',
output: 'cucumber_report.html',
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
'App Version': '1.0.0',
'Test Environment': 'PRODUCTION',
'Browser': 'Firefox 89.0',
'Platform': 'macOS Big Sur',
'Parallel': 'Scenarios',
'Executed': 'Local'
}
};
reporter.generate(options);
Launch Report Automatically
This feature allows you to automatically launch the generated HTML report in the default web browser after it is created. This is useful for quickly viewing the test results without manually opening the file.
const reporter = require('cucumber-html-reporter');
const options = {
theme: 'bootstrap',
jsonFile: 'cucumber_report.json',
output: 'cucumber_report.html',
reportSuiteAsScenarios: true,
launchReport: true
};
reporter.generate(options);
Other packages similar to cucumber-html-reporter
cucumber-html-reporter
The cucumber-html-reporter package is a popular choice for generating HTML reports from Cucumber JSON reports. It offers a variety of themes and customization options, making it easy to create visually appealing and informative reports.
multiple-cucumber-html-reporter
The multiple-cucumber-html-reporter package is another option for generating HTML reports from Cucumber JSON reports. It supports multiple JSON files and provides additional features such as embedding screenshots and displaying step definitions. It is more feature-rich compared to cucumber-html-reporter.
cucumber-html-reporter
The cucumber-html-reporter package is a popular choice for generating HTML reports from Cucumber JSON reports. It offers a variety of themes and customization options, making it easy to create visually appealing and informative reports.
cucumber-html-reporter
Generate Cucumber HTML reports with pie charts
Available HTML themes: ['bootstrap', 'foundation', 'simple']
Preview of HTML Reports
- Bootstrap Theme Reports with Pie Chart
- Foundation Theme Reports
- Simple Theme Reports
Snapshot of Bootstrap Report
Install
npm install cucumber-html-reporter --save-dev
Usage
Example of bootstrap
theme:
var reporter = require('cucumber-html-reporter');
var options = {
theme: 'bootstrap',
jsonFile: 'test/report/cucumber_report.json',
output: 'test/report/cucumber_report.html',
reportSuiteAsScenarios: true
};
reporter.generate(options);
Plugin the above code to the cucumber's AfterFeatures
hook
Options
theme
Available: ['bootstrap', 'foundation', 'simple']
Type: String
Select the Theme for HTML report.
jsonFile
Type: String
Provide path of the Cucumber JSON format file
output
Type: String
Provide HTML output file path and name
reportSuiteAsScenarios
Type: Boolean
Supported in the Bootstrap theme.
true
: Reports total number of passed/failed scenarios as HEADER.
false
: Reports total number of passed/failed features as HEADER.
Credits
Credit to the developers of grunt-cucumberjs for developing pretty HTML reporting. HTML reporting is extracted from the grunt task. Thanks to all the contributors for making HTML Reporting available to the wider audiences of cucumber-js community.