Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
jest-html-reporter
Advanced tools
Readme
A Jest test results processor for generating a summary in HTML.
Documentation »
Inspired by karma-htmlfile-reporter
npm install jest-html-reporter --save-dev
Configure Jest to process the test results by adding the following entry to the Jest config (jest.config.js):
{
"testResultsProcessor": "./node_modules/jest-html-reporter"
}
Then when you run Jest from within the terminal, a file called test-report.html will be created within your root folder containing information about your tests.
Although jest.config.js is specifically created for configuring Jest (and not this plugin), it is possible to configure Jest from within package.json by adding the following as a new line:
"jest": {"testResultsProcessor": "./node_modules/jest-html-reporter" }
This plugin is compatible with Node version ^4.8.3
To configure this plugin, create a file named jesthtmlreporter.config.json
in the root folder of the project. Please note that all configuration properties are optional.
Property | Type | Description | Default |
---|---|---|---|
pageTitle | STRING | The title of the document. This string will also be outputted on the top of the page. | "Test Suite" |
outputPath | STRING | The path to where the plugin will output the HTML report. The path must include the filename and end with .html | "./test-report.html" |
includeFailureMsg | BOOLEAN | If this setting is set to true, this will output the detailed failure message for each failed test. | false |
styleOverridePath | STRING | The path to a file containing CSS styles that should override the default styling.* | null |
theme | STRING | The name of the reporter themes to use when rendering the report. Available themes are located within style/ | "defaultTheme" |
executionTimeWarningThreshold | NUMBER | The threshold for test execution time (in seconds) in each test suite that will render a warning on the report page. 5 seconds is the default timeout in Jest. | 5 |
dateFormat | STRING | The format in which date/time should be formatted in the test report. Have a look in the Wiki for the available date format variables. | "yyyy-mm-dd HH:MM:ss" |
The plugin will search for the file from the root directory, therefore there is no need to prepend the string with ./ or ../
Have a look at the default styling (located within style/defaultTheme.css) for a reference of the elements available for styling.
{
"pageTitle": "Your test suite",
"outputPath": "test-report/index.html",
"includeFailureMsg": false,
"styleOverridePath": "src/teststyle.css",
"executionTimeWarningThreshold": 5,
"dateFormat": "yyyy-mm-dd HH:MM:ss"
}
Add an entry named "jest-html-reporter" to your package.json
{
...
"jest-html-reporter": {
"pageTitle": "Your test suite",
"outputPath": "test-report.html",
"includeFailureMsg": true
}
}
Configuration may also be performed with environment variables for dynamic file saving paths in different environments.
NOTE: jesthtmlreporter.config.json and package.json will take precedence over environment variables.
Here is an example of dynamically naming your output file and test report title to match your current branch that one might see in a automated deployment pipeline before running their tests.
export BRANCH_NAME=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`
export JEST_HTML_REPORTER_OUTPUT_PATH=/home/username/jest-test-output/test-reports/"$BRANCH_NAME".html
export JEST_HTML_REPORTER_PAGE_TITLE="$BRANCH_NAME"\ Test\ Report
The environment variables reflect the properties set in the JSON configuration file. Please read the documentation for more information.
JEST_HTML_REPORTER_PAGE_TITLE
JEST_HTML_REPORTER_OUTPUT_PATH
JEST_HTML_REPORTER_INCLUDE_FAILURE_MSG
JEST_HTML_REPORTER_STYLE_OVERRIDE_PATH
JEST_HTML_REPORTER_THEME
JEST_HTML_REPORTER_EXECUTION_TIME_WARNING_THRESHOLD
JEST_HTML_REPORTER_DATE_FORMAT
FAQs
Jest test results processor for generating a summary in HTML
We found that jest-html-reporter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).