Gathering detailed insights and metrics for @andrewzenzin/jest-html-reporters
Gathering detailed insights and metrics for @andrewzenzin/jest-html-reporters
npm install @andrewzenzin/jest-html-reporters
Typescript
Module System
Node Version
NPM Version
74.5
Supply Chain
99.5
Quality
75.8
Maintenance
100
Vulnerability
100
License
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! 🚀
Total Downloads
3,192
Last Day
1
Last Week
4
Last Month
36
Last Year
387
MIT License
526 Stars
244 Commits
103 Forks
7 Watchers
4 Branches
25 Contributors
Updated on Jan 31, 2025
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
Cumulative downloads
Total Downloads
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
58
Jest test results processor for generating a summary in HTML
1 npm install jest-html-reporters --save-dev
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.
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 |
1..., 2"reporters": [ 3 "default", 4 ["jest-html-reporters", { 5 "publicPath": "./html-report", 6 "filename": "report.html", 7 "openReport": true 8 }] 9]
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
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
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
Reason
packaging workflow detected
Details
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
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
25 existing vulnerabilities detected
Details
Score
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