
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
jest-html-reporter
Advanced tools
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.
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"
}
]
]
}
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 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.
π
A Jest test results processor for generating a summary in HTML.
Inspired by karma-htmlfile-reporter
npm:
$ npm install jest-html-reporter --save-dev
yarn:
$ yarn add jest-html-reporter --dev
Configure Jest to process the test results by adding the following entry to the Jest config (jest.config.json):
"reporters": [
"default",
["./node_modules/jest-html-reporter", {
"pageTitle": "Test Report"
}]
]
As you run Jest from within the terminal, a file called test-report.html will be created within your root folder containing information about your tests.
There are multiple configuration options available. Read more about these further down in this document.
To run the reporter as a test results processor (after Jest is complete instead of running in parallel), add the following entry to the Jest config (jest.config.json):
{
"testResultsProcessor": "./node_modules/jest-html-reporter"
}
Note: When running as a testResultsProcessor, the configuration needs either to be placed within a new file named jesthtmlreporter.config.json
residing in the root folder
{
"pageTitle": "Test Report",
}
or via adding a key to package.json
named "jest-html-reporter":
{
...
"jest-html-reporter": {
"pageTitle": "Test Report",
}
}
Option | Type | Default | Description |
---|---|---|---|
additionalInformation | Array<{ label: string; value: string; }> | null | A list of additional information to be added to the top of the report. |
append | boolean | false | Append test results to an existing report. |
boilerplate | string | null | Path to an HTML boilerplate file. The {jesthtmlreporter-content} variable will be replaced with test results. |
collapseSuitesByDefault | boolean | false | Collapse test suites (accordions) by default. |
customScriptPath | string | null | Path to an external script file injected into the report. |
dateFormat | string | yyyy-mm-dd HH:MM:ss | Date format for timestamps. See documentation for available formats. |
executionTimeWarningThreshold | number | 5 | Warn if a test suite exceeds this execution time (in seconds). |
includeConsoleLog | boolean | false | Include console.log outputs in the report (requires --verbose=false ). |
includeFailureMsg | boolean | false | Show detailed error messages for failed tests. |
includeStackTrace | boolean | true | Show stack traces for failed tests. |
includeSuiteFailure | boolean | false | Show detailed errors for entire failed test suites. |
includeObsoleteSnapshots | boolean | false | Show obsolete snapshot names. |
logo | string | null | Path to an image file to display in the report header. |
outputPath | string | ./test-report.html | Full path for the output report file (must end in .html ). |
pageTitle | string | "Test Report" | Title of the document and top-level heading. |
sort | string | null | Sort test results by a specific method. Available values: β€ status β Sorts by test status (pending β failed β passed).β€ status:{custom-order} β Custom status order (e.g., "status:failed,passed,pending" ).β€ executionasc β Sorts by execution time ascending.β€ executiondesc β Sorts by execution time descending.β€ titleasc β Sorts by suite filename/test name ascending.β€ titledesc β Sorts by suite filename/test name descending. |
statusIgnoreFilter | string | null | Comma-separated list of statuses to exclude: "passed" , "pending" , "failed" . |
styleOverridePath | string | null | Path to a CSS file to override default styles. |
useCssFile | boolean | false | Link to the CSS file instead of inlining styles. |
All the configuration options provided in the table above are available via environment variables and follows the pattern of snake case in uppercase prepended with JEST_HTML_REPORTER_
Example: customScriptPath
-> JEST_HTML_REPORTER_CUSTOM_SCRIPT_PATH
*NOTE: Environment variables will take precedence over configurations set in jesthtmlreporter.config.json and package.json*
Here is an example of dynamically naming your output file and test report title to match your current branch that one might see in a automated deployment pipeline before running their tests.
export BRANCH_NAME=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`
export JEST_HTML_REPORTER_OUTPUT_PATH=/home/username/jest-test-output/test-reports/"$BRANCH_NAME".html
export JEST_HTML_REPORTER_PAGE_TITLE="$BRANCH_NAME"\ Test\ Report
FAQs
Jest test results processor for generating a summary in HTML
The npm package jest-html-reporter receives a total of 224,281 weekly downloads. As such, jest-html-reporter popularity was classified as popular.
We found that jest-html-reporter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fixβa new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.