Registry / testing / jest-html-reporters

jest-html-reporters

JSON →
library3.1.7jsnpmunverified

jest-html-reporters is a Jest test results processor that generates an interactive HTML summary of test execution. Currently at version 3.1.7, it receives regular maintenance updates with frequent minor releases addressing bug fixes and adding new features like dark mode support and console log integration. Key differentiators include its ability to produce a standalone HTML file, offering features such as sorting, filtering by test status, displaying detailed failure messages, and custom branding options. Unlike simple console reporters, it provides a persistent, shareable artifact of test runs, making it valuable for continuous integration environments and team collaboration, facilitating quick overviews of test health and granular investigation into failures.

npm install jest-html-reporters
INSTALL
IMPORT
SIG · JEST-HTML-REPORTER
J
jest-html-reporters
testingjavascriptv3.1.7
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

JestHtmlReporter
✓ import JestHtmlReporter from 'jest-html-reporters';
✗ import { JestHtmlReporter } from 'jest-html-reporters';
JestHtmlReporter is a default export, primarily for programmatic usage or custom Jest environments, not typical reporter configuration via `jest.config.json`.
JestHtmlReporter
✓ const JestHtmlReporter = require('jest-html-reporters');
CommonJS import for programmatic usage in Node.js environments. The primary usage is via Jest's configuration array.
ReporterOptions
✓ import type { ReporterOptions } from 'jest-html-reporters';
✗ import { ReporterOptions } from 'jest-html-reporters';
Imports the TypeScript interface for defining reporter configuration options, useful for type-checking custom configurations.

This quickstart demonstrates how to configure jest-html-reporters in a TypeScript Jest project, including custom options like dark theme, console log inclusion, and custom filenames. It also shows a simple test file with passing, failing, and skipped tests, along with console output. Note the use of `--verbose=false` to ensure console logs are captured.

// jest.config.ts import type { Config } from 'jest'; const config: Config = { testEnvironment: 'node', reporters: [ 'default', [ 'jest-html-reporters', { publicPath: './html-report', filename: 'test-report.html', expand: true, darkTheme: true, includeConsoleLog: true, pageTitle: 'My Project Test Report' } ] ] }; export default config; // my-test.test.ts describe('User Authentication', () => { test('should allow a valid user to log in', () => { console.log('Attempting login for valid user...'); expect(true).toBe(true); }); test('should reject invalid credentials', () => { console.warn('Invalid credentials test initiated.'); expect(false).toBe(true); // This test will fail }); test.skip('should handle session timeout', () => { console.info('Skipped session timeout test.'); expect(true).toBe(false); }); }); // To run: // npm install --save-dev jest jest-html-reporters typescript ts-jest @types/jest // Add script in package.json: "test": "jest --verbose=false --config jest.config.ts" // Then run: npm test
Debug
Known issues
gotchaTo capture and display console logs within the HTML report using the `includeConsoleLog` option, Jest must be run with `--verbose=false`. Running with `--verbose=true` will prevent logs from being captured by the reporter.
fix
Ensure your Jest command includes `--verbose=false` when `includeConsoleLog` is enabled in your reporter options. Example: `jest --verbose=false`.
affects: >=3.1.2
gotchaThe `openReport` option automatically opens the generated HTML report in the browser. By default, it's `true` in development environments and `false` in other environments. This can lead to unexpected browser launches in CI/production if not explicitly set to `false`.
fix
Explicitly set `openReport: false` in your reporter options within `jest.config.json` for CI/production environments to prevent automatic browser opening.
affects: >=3.1.0
gotchaWhen upgrading from versions prior to 3.1.4, be aware of fixes related to circular object cloning. If your tests generate circular JSON objects in their results (e.g., from `console.log` output or complex error objects), older versions might fail to generate a report or throw errors. Newer versions handle this robustly.
fix
Upgrade to `jest-html-reporters@3.1.4` or newer to ensure proper handling of circular objects in test results, which can prevent report generation failures.
affects: <3.1.4
Errors
Common errors & fixes
Configuration error: Unknown reporter 'jest-html-reporters'
The package `jest-html-reporters` is not installed or not resolvable in your project's `node_modules`.
fix
Install the package as a development dependency: `npm install jest-html-reporters --save-dev` or `yarn add jest-html-reporters --dev`.
Report file not found: jest_html_reporters.html
The HTML report file was not generated, possibly due to incorrect Jest configuration, a custom `filename` or `publicPath` setting, or the `failureMessageOnly` option preventing report creation.
fix
Check your `jest.config.json` for correct `publicPath` and `filename` settings. Also, verify `failureMessageOnly` is not set to `2` if you expect a report even when all tests pass, or ensure some tests are failing if it is.
console.log output is missing from the HTML report despite `includeConsoleLog: true`.
Jest's default verbosity (or `--verbose=true`) can interfere with the reporter's ability to capture console output.
fix
Run Jest with the `--verbose=false` flag to allow the reporter to correctly capture console logs. For example: `jest --verbose=false`.
Upgrade
Version history
3.1.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
jest-html-reporters — npm install jest-html-reporters · libregistry