Gathering detailed insights and metrics for jest-html-reporters
Gathering detailed insights and metrics for jest-html-reporters
Gathering detailed insights and metrics for jest-html-reporters
Gathering detailed insights and metrics for jest-html-reporters
jest-junit
A jest reporter that generates junit xml files
jest-stare
jest html reporter (results processor) to view HTML jest results, save raw JSON, and invoke multiple reporters
jest-html-reporter
Jest test results processor for generating a summary in HTML
jest-silent-reporter
A silent reporter for Jest
npm install jest-html-reporters
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
522 Stars
244 Commits
101 Forks
7 Watching
4 Branches
25 Contributors
Updated on 11 Nov 2024
JavaScript (49.31%)
TypeScript (42.91%)
HTML (5.52%)
SCSS (1.95%)
Shell (0.31%)
Cumulative downloads
Total Downloads
Last day
-8.4%
37,122
Compared to previous day
Last week
-0.6%
211,013
Compared to previous week
Last month
4%
901,325
Compared to previous month
Last year
14.8%
11,764,135
Compared to previous year
74
English | 简体ä¸æ–‡
Jest test results processor for generating a summary in HTML
Example page https://hazyzh.github.io/report.html
1 # yarn 2 yarn add jest-html-reporters --dev 3 # npm 4 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 | Type | Default | Description | env variables name |
---|---|---|---|---|
publicPath | string | '' | specify the base path | JEST_HTML_REPORTERS_PUBLIC_PATH |
filename | string | jest_html_reporters.html | Filename of saved report Applies to the generated html | JEST_HTML_REPORTERS_FILE_NAME |
includeConsoleLog | boolean | false | set true to display console logs for each test suite. NOTE: the precondition is to run Jest with --verbose=false in order to catch all logs during the tests. | JEST_HTML_REPORTERS_INCLUDE_CONSOLE_LOG |
darkTheme | boolean | false | set true to generate dark theme report page | JEST_HTML_REPORTERS_DARK_THEME |
failureMessageOnly | number | 0 | 0 : always create report. 1 : show failure test suites messages only in Report. 2 : only create report when some test suites failed. | JEST_HTML_REPORTERS_FAILURE_MESSAGE_ONLY |
inlineSource | boolean | false | Option to save report in a single combined HTML file #184 | JEST_HTML_REPORTERS_INLINE_SOURCE |
pageTitle | string | Report | specify header and page title | JEST_HTML_REPORTERS_PAGE_TITLE |
logoImgPath | string | undefined | specify path of the image that will be displayed to the right of page title | JEST_HTML_REPORTERS_LOGO_IMG_PATH |
hideIcon | boolean | false | hide default icon | JEST_HTML_REPORTERS_HIDE_ICON |
expand | boolean | false | specify whether default expand all data | JEST_HTML_REPORTERS_EXPAND |
testCommand | string | "" | copy command content to quickly run test file | JEST_HTML_REPORTERS_TEST_COMMAND |
openReport | boolean | in dev=true, rest=false | options for npm package open | JEST_HTML_REPORTERS_OPEN_REPORT |
urlForTestFiles | string | '' | url for test files. If user set this value, Details table shows an icon link to each rows. The link is constructed by joining urlForTestFiles and relativePath (like /src/utils/index.test.js ) for each tests. See the detail in #221 | JEST_HTML_REPORTERS_URL_FOR_TEST_FILES |
customInfos | 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 | JEST_HTML_REPORTERS_CUSTOM_INFOS |
enableMergeData | boolean | false | for default enable merge test data feature | JEST_HTML_REPORTERS_ENABLE_MERGE_DATA |
dataMergeLevel | number | 1 | default merge test data level | JEST_HTML_REPORTERS_DATA_MERGE_LEVEL |
env only | string | system default temporary directory | path to a temporary folder with attachments | JEST_HTML_REPORTERS_TEMP_DIR_PATH |
stripSkippedTest | boolean | false | skip the pending tests and suites in the final report | JEST_HTML_REPORTERS_STRIP_SKIPPED_TEST |
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 | object;
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 | object} options.message - message string
* @param {any} [options.context] - custom context (optional)
*/
const addMsg = async ({ message, context }) => { ... }
Only one parameter is required. If you pass an serializable object like, it will auth using JSON.stringify(object, null, 2)
to save the object and then prettified it in report.
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: { won: 1, too: 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
If user set some value to urlForTestFiles
, Details table shows an icon link to each rows. The link is constructed by joining urlForTestFiles (ex: https://github.com/Hazyzh/jest-html-reporters/blob/master
) and relativePath (ex: /src/utils/index.test.js
) for each tests.
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
22 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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