What is jest-html-reporter?
jest-html-reporter is a Jest test results processor that generates a customizable HTML report. It helps in visualizing test results in a more readable and accessible format.
What are jest-html-reporter's main functionalities?
Basic HTML Report
This configuration generates a basic HTML report with a custom page title. It is added to the Jest configuration file (jest.config.js or package.json).
{
"reporters": [
"default",
[
"jest-html-reporter",
{
"pageTitle": "Test Report"
}
]
]
}
Custom Output Path
This configuration specifies a custom output path for the HTML report. The report will be saved to the specified location.
{
"reporters": [
"default",
[
"jest-html-reporter",
{
"outputPath": "./reports/test-report.html"
}
]
]
}
Custom Report Title and Theme
This configuration allows setting a custom title and theme for the HTML report. The 'darkTheme' option provides a dark-themed report.
{
"reporters": [
"default",
[
"jest-html-reporter",
{
"pageTitle": "My Custom Test Report",
"theme": "darkTheme"
}
]
]
}
Include Failure Messages
This configuration includes detailed failure messages in the HTML report, making it easier to debug test failures.
{
"reporters": [
"default",
[
"jest-html-reporter",
{
"includeFailureMsg": true
}
]
]
}
Sort Results
This configuration sorts the test results in the HTML report by status, making it easier to identify failed tests.
{
"reporters": [
"default",
[
"jest-html-reporter",
{
"sort": "status"
}
]
]
}
Other packages similar to jest-html-reporter
jest-stare
jest-stare is another Jest test results processor that generates an HTML report. It provides a more detailed and interactive report compared to jest-html-reporter, including charts and graphs for better visualization.
jest-html-reporters
jest-html-reporters is a highly customizable HTML report generator for Jest. It supports multiple themes, custom styles, and additional data like screenshots and logs, making it more versatile than jest-html-reporter.
jest-html-reporter
A jest test results processor for generating a summary in HTML. This plugin will generate a test summary file in HTML.
This plugin was inspired by karma-htmlfile-reporter
Installation
npm install jest-html-reporter
Usage
You must configure jest to process the test results by adding the following entry to the jest config:
{
"testResultsProcessor": "./node_modules/jest-html-reporter"
}
Then when you run jest from within the terminal, a file called test-report.html will be created within your root folder containing general information about your tests.
Configuration
The configurations are done directly within your package.json file
{
...
"jest-html-reporter": {
"pageTitle": "Your test suite",
"output": "test-report/index.html"
}
}