What is @cucumber/html-formatter?
@cucumber/html-formatter is an npm package that provides a way to generate HTML reports from Cucumber JSON output. It is useful for visualizing the results of Cucumber tests in a more readable and user-friendly format.
What are @cucumber/html-formatter's main functionalities?
Generate HTML Report
This feature allows you to generate an HTML report from a Cucumber JSON report. You need to specify the input JSON file and the output HTML file. The `generate` function processes the JSON and creates a formatted HTML report.
const { generate } = require('@cucumber/html-formatter');
const options = {
input: 'path/to/cucumber-report.json',
output: 'path/to/output.html'
};
generate(options).then(() => {
console.log('HTML report generated successfully!');
}).catch(err => {
console.error('Error generating HTML report:', err);
});
Other packages similar to @cucumber/html-formatter
cucumber-html-reporter
cucumber-html-reporter is another package that generates HTML reports from Cucumber JSON output. It offers customization options for the report layout and styling. Compared to @cucumber/html-formatter, it provides more flexibility in terms of report customization.
cucumber-html
cucumber-html is a package that also generates HTML reports from Cucumber JSON output. It is a simpler alternative to @cucumber/html-formatter, focusing on ease of use and quick setup. It may lack some advanced customization features available in @cucumber/html-formatter.
multiple-cucumber-html-reporter
multiple-cucumber-html-reporter is a package designed to generate HTML reports from multiple Cucumber JSON files. It supports merging multiple reports into a single HTML file, which can be useful for large projects with multiple test suites. It offers more advanced features compared to @cucumber/html-formatter, such as embedding screenshots and detailed metadata.
cucumber-html-formatter
For general information, see the parent README.md
Hacking
While hacking on this module you may want to try it out manually. For example,
to generate a report with random results for the .feature
files used in gherkin's
test suite:
cd ../../gherkin
../fake-cucumber/javascript/bin/fake-cucumber \
--results random \
testdata/good/*.feature | \
../html-formatter/javascript/bin/cucumber-html-formatter.js > \
gherkin.html
Docker image
The Docker image is automatically built on docker hub, but you can also build it locally:
source ../../scripts/functions.sh
docker_build Dockerfile