Registry / testing / jest-html-reporter

jest-html-reporter

JSON →
library4.4.0jsnpmunverified

jest-html-reporter is a Jest test results processor designed to generate a comprehensive HTML summary of test runs. The current stable version is 4.4.0, demonstrating active maintenance with frequent patch and minor releases. It provides a visual, interactive report that includes test status, detailed results, console logs, and stack traces, offering a more user-friendly overview than standard terminal output. Key features include extensive configuration options such as custom page titles, theme selection (including a dark theme since v4.3.0), the ability to include additional information sections, and fine-grained control over console log origins and stack trace inclusion. This reporter integrates directly into Jest's configuration, functioning either as an entry in the `reporters` array for concurrent processing or as a `testResultsProcessor` for post-run analysis. Its primary purpose is to enhance the observability and shareability of test outcomes.

npm install jest-html-reporter
INSTALL
IMPORT
SIG · JEST-HTML-REPORTER
J
jest-html-reporter
testingjavascriptv4.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Reporter configuration for 'reporters' array
["./node_modules/jest-html-reporter", { "outputPath": "./test-report.html", "pageTitle": "My Report" }]
import { JestHtmlReporter } from 'jest-html-reporter';
The reporter is configured as a string path within Jest's `reporters` array in `jest.config.json`, optionally with an options object. It is not directly imported into JavaScript/TypeScript files.
Processor configuration for 'testResultsProcessor'
"./node_modules/jest-html-reporter"
require('jest-html-reporter');
When used as a `testResultsProcessor` in `jest.config.json`, the reporter is referenced by its module path. Configuration options for this mode must be placed in `jesthtmlreporter.config.json` or under the `jest-html-reporter` key in `package.json`.
Direct module import (incorrect)
(Configure in `jest.config.json` as shown above)
import JestHtmlReporter from 'jest-html-reporter'; // or const reporter = require('jest-html-reporter');
This package is a Jest plugin and is not designed for direct module import into user application code. It is loaded and executed exclusively by the Jest test runner based on its configuration.

This Jest configuration snippet demonstrates how to integrate `jest-html-reporter` as a reporter. It outputs a dark-themed HTML report named `test-report.html` with a custom title, including stack traces, and additional contextual information.

{ "testEnvironment": "node", "reporters": [ "default", [ "./node_modules/jest-html-reporter", { "outputPath": "./test-report.html", "pageTitle": "My Project Test Report", "darkTheme": true, "includeStackTrace": true, "additionalInformation": [ { "label": "Project", "value": "My Awesome App" }, { "label": "Environment", "value": process.env.NODE_ENV ?? "development" } ] } ] ] }
Debug
Known issues
breakingThe environment variable for status filtering was renamed from `JEST_HTML_REPORTER_STATUS_FILTER` to `JEST_HTML_REPORTER_STATUS_IGNORE_FILTER`.
fix
Update any environment variables referencing the old name to `JEST_HTML_REPORTER_STATUS_IGNORE_FILTER`.
affects: >=4.0.0
gotchaConfiguration options for `jest-html-reporter` differ based on whether it's used as a `reporter` (in the `reporters` array) or a `testResultsProcessor`.
fix
When using `testResultsProcessor`, place configuration in a separate file named `jesthtmlreporter.config.json` in the project root, or under the `jest-html-reporter` key in `package.json`. Direct options within `jest.config.json` are only supported for the `reporters` array.
affects: >=3.0.0
gotchaAs of v4.3.1, using invalid configuration keys will trigger an alert in the console during Jest execution.
fix
Review your `jest.config.json` or `jesthtmlreporter.config.json` for misspelled or unsupported configuration options. Refer to the official documentation for a list of valid keys.
affects: >=4.3.1
gotchaThe documented default value for `hideConsoleLogOrigin` was corrected to `false` in v4.3.1, meaning console log origins are shown by default.
fix
If you rely on console log origins being hidden by default, explicitly set `hideConsoleLogOrigin: true` in your configuration to maintain the desired behavior.
affects: >=4.3.1
Errors
Common errors & fixes
Jest HTML Reporter: Cannot find module './node_modules/jest-html-reporter' from 'jest.config.json'
The package `jest-html-reporter` is either not installed or the path specified in `jest.config.json` is incorrect.
fix
Ensure `jest-html-reporter` is installed (`npm install jest-html-reporter --save-dev` or `yarn add jest-html-reporter --dev`) and verify the module path in your Jest configuration.
Jest HTML Reporter: Invalid configuration key found: 'outputDir'
A configuration option used in your reporter setup is not recognized or is misspelled. The actual option for output directory is `outputPath`.
fix
Check the `jest-html-reporter` documentation for the correct spelling and available configuration options. For example, change `'outputDir'` to `'outputPath'`.
TypeError: Cannot read properties of undefined (reading 'length') in jest-html-reporter
This can occur if the reporter is configured without an options object when used in the `reporters` array, but the reporter expects one, or if an option value is of the wrong type.
fix
When configuring the reporter in the `reporters` array, ensure you provide an options object as the second element: `['./node_modules/jest-html-reporter', { /* options here */ }]`. Also, verify that all option values match their expected types (e.g., `outputPath` is a string).
Upgrade
Version history
4.4.0latest on npm
Audit
Dependencies
jestrequiredPeer dependency as it functions as a Jest test results processor/reporter.
Agent activity
4 hits · last 30 days
node
4
Resources
jest-html-reporter — npm install jest-html-reporter · libregistry