Installations
npm install @andrewzenzin/jest-html-reporters
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
12.22.7
NPM Version
6.14.15
Score
74.5
Supply Chain
99.5
Quality
75.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (49.31%)
TypeScript (42.91%)
HTML (5.52%)
SCSS (1.95%)
Shell (0.31%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
3,192
Last Day
1
Last Week
4
Last Month
36
Last Year
387
GitHub Statistics
MIT License
526 Stars
244 Commits
103 Forks
7 Watchers
4 Branches
25 Contributors
Updated on Jan 31, 2025
Package Meta Information
Latest Version
3.2.2
Package Id
@andrewzenzin/jest-html-reporters@3.2.2
Unpacked Size
3.68 MB
Size
915.41 kB
File Count
10
NPM Version
6.14.15
Node Version
12.22.7
Total Downloads
Cumulative downloads
Total Downloads
3,192
Last Day
0%
1
Compared to previous day
Last Week
300%
4
Compared to previous week
Last Month
63.6%
36
Compared to previous month
Last Year
-63%
387
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
58
Jest reporter
Jest test results processor for generating a summary in HTML
Installation
1 npm install jest-html-reporters --save-dev
Usage
Configure Jest to process the test results by adding the following entry to the Jest config (jest.config.json):
1"jest": { 2 ..., 3 "reporters": [ 4 "default", 5 "jest-html-reporters" 6 ], 7 ... 8} 9
As you run Jest from within the terminal, a file called jest_html_reporters.html
will be created within your root folder containing information about your tests.
Available Options
The options below are specific to the reporter.
Option Name | env variables name | Type | Default | Description |
---|---|---|---|---|
publicPath | JEST_HTML_REPORTERS_PUBLIC_PATH | string | '' | specify the base path |
filename | JEST_HTML_REPORTERS_FILE_NAME | string | jest_html_reporters.html | Filename of saved report Applies to the generated html |
expand | JEST_HTML_REPORTERS_EXPAND | Boolean | false | specify whether default expand all data |
pageTitle | JEST_HTML_REPORTERS_PAGE_TITLE | string | Report | specify header and page title |
logoImgPath | JEST_HTML_REPORTERS_LOGO_IMG_PATH | string | undefined | specify path of the image that will be displayed to the right of page title |
hideIcon | JEST_HTML_REPORTERS_HIDE_ICON | boolean | false | hide default icon |
customInfos | JEST_HTML_REPORTERS_CUSTOM_INFOS | array | undefined | show some custom data info in the report, example value [ {title: 'test1', value: 'test1'}, {title: 'test2', value: 'test2'}] , you can also set value to a environment variable JEST_HTML_REPORTERS_CUSTOM_INFOS, see detail in #32 |
testCommand | JEST_HTML_REPORTERS_TEST_COMMAND | string | "npx jest" | copy command content to quickly run test file |
openReport | JEST_HTML_REPORTERS_OPEN_REPORT | json | in dev=true, rest=false | options for npm package open |
env variable support only | JEST_HTML_REPORTERS_TEMP_DIR_PATH | string | system default temporary directory | path to a temporary folder with attachments |
failureMessageOnly | JEST_HTML_REPORTERS_FAILURE_MESSAGE_ONLY | boolean | false | show failure test suites messages only in HTML report |
enableMergeData | JEST_HTML_REPORTERS_ENABLE_MERGE_DATA | boolean | false | for default enable merge test data feature |
dataMergeLevel | JEST_HTML_REPORTERS_DATA_MERGE_LEVEL | number | 1 | default merge test data level |
inlineSource | JEST_HTML_REPORTERS_INLINE_SOURCE | boolean | false | Option to save report in a single combined HTML file #184 |
example add config options
1..., 2"reporters": [ 3 "default", 4 ["jest-html-reporters", { 5 "publicPath": "./html-report", 6 "filename": "report.html", 7 "openReport": true 8 }] 9]
some features.
- Collapsable Test Groups
This feature regrading to #37, if a test file has many test cases, here will show a Merge Data checkbox on the expanded table. You can check it to merge data and set the merge level to control how to combine those data.
For Example
- Attach screenshot to report
This feature regrading to #36, this package will a new method named addAttach
.
interface IAddAttachParams {
attach: string | Buffer;
description: string;
context: any;
bufferFormat: string;
}
There are three params of this method, description
is easy to understand. The param attach
referring to the image, you can pass a buffer
or string
, if it was a buffer the package will help you create a dir named jest-html-reporters-attach
and save that buffer
as a jpg
image in it under the publicPath
. if you have already saved the image, just pass the image's path as the attach
param.
context
is an optional parameter. Here can be specified context (default is this.global).
Here is an Example with puppeteer.
1// Example attach with **buffer** 2const { addAttach } = require("jest-html-reporters/helper"); 3const puppeteer = require("puppeteer"); 4 5describe("just examples", () => { 6 test("test buffer", async () => { 7 const browser = await puppeteer.launch(); 8 const page = await browser.newPage(); 9 await page.goto("https://www.google.com"); 10 const data = await page.screenshot(); 11 await browser.close(); 12 await addAttach({ 13 attach: data, 14 description: 'img 1', 15 }); 16 await addAttach({ 17 attach: await fs.readFileSync('./test.mp4'), 18 description: 'img 1', 19 bufferFormat: 'mp4', 20 }); 21 expect(1).toBe(1); 22 }); 23});
1// Example attach with **string** 2const { addAttach } = require("jest-html-reporters/helper"); 3const puppeteer = require("puppeteer"); 4const path = require("path"); 5 6describe("just examples", () => { 7 test("case string", async () => { 8 const filePath = path.resolve(__dirname, "./test.jpg"); 9 await browser.close(); 10 await addAttach({ 11 attach: filePath, 12 description: 'test google 2', 13 }); 14 15 await addAttach({ 16 attach: 'www.example.com/test.mp4', 17 description: 'test video 2', 18 }); 19 expect(1).toBe(2); 20 }); 21});
it will show like this
- Attach a message to the report
This feature is in regards to #63 & #64. It allows you to add a message or log something to the html report with addMsg()
/**
* @param {object} options - options object
* @param {string} options.message - message string
* @param {any} [options.context] - custom context (optional)
*/
const addMsg = async ({ message, context }) => { ... }
Only one parameter is required. If you stringify an object like this JSON.stringify(object, null, 2)
, the object will be prettified.
context
is an optional parameter. Here can be specified context (default is this.global).
Here is an Example with Nightmare.
1const { addAttach, addMsg } = require("jest-html-reporters/helper"); 2const Nightmare = require("nightmare"); 3 4describe("Yet another example", () => { 5 test("Both addAttach & addMsg with failure", async () => { 6 const nightmare = Nightmare({ show: true }); 7 await addMsg({ message: JSON.stringify({ won: 1, too: 2 }, null, 2) }); 8 await nightmare.goto("https://duckduckgo.com"); 9 const s1 = await nightmare.screenshot(); 10 await addAttach(s1, "test duckduckgo 1"); 11 await nightmare.end(); 12 await addMsg({ message: JSON.stringify(process, null, 2) }); 13 expect(2).toEqual(1); 14 }, 20000); 15 test("addMsg with success", async () => { 16 await addMsg({ message: JSON.stringify({ free: 3, for: 4 }, null, 2) }); 17 expect(2).toEqual(2); 18 }); 19});
Message still displays without screenshots and with a successful test

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/npm-publish.yml:11
Reason
Found 2/21 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/tests.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/Hazyzh/jest-html-reporters/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/Hazyzh/jest-html-reporters/npm-publish.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/Hazyzh/jest-html-reporters/npm-publish.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/Hazyzh/jest-html-reporters/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/Hazyzh/jest-html-reporters/tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/Hazyzh/jest-html-reporters/tests.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/Hazyzh/jest-html-reporters/tests.yml/master?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 3 third-party GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 22 are checked with a SAST tool
Reason
25 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
3.2
/10
Last Scanned on 2025-02-17
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More