Socket
Socket
Sign inDemoInstall

jest-html-reporter

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-html-reporter

Jest test results processor for generating a summary in HTML


Version published
Weekly downloads
233K
increased by11%
Maintainers
1
Weekly downloads
 
Created

Package description

What is jest-html-reporter?

jest-html-reporter is a Jest test results processor that generates a customizable HTML report. It helps in visualizing test results in a more readable and accessible format.

What are jest-html-reporter's main functionalities?

Basic HTML Report

This configuration generates a basic HTML report with a custom page title. It is added to the Jest configuration file (jest.config.js or package.json).

{
  "reporters": [
    "default",
    [
      "jest-html-reporter",
      {
        "pageTitle": "Test Report"
      }
    ]
  ]
}

Custom Output Path

This configuration specifies a custom output path for the HTML report. The report will be saved to the specified location.

{
  "reporters": [
    "default",
    [
      "jest-html-reporter",
      {
        "outputPath": "./reports/test-report.html"
      }
    ]
  ]
}

Custom Report Title and Theme

This configuration allows setting a custom title and theme for the HTML report. The 'darkTheme' option provides a dark-themed report.

{
  "reporters": [
    "default",
    [
      "jest-html-reporter",
      {
        "pageTitle": "My Custom Test Report",
        "theme": "darkTheme"
      }
    ]
  ]
}

Include Failure Messages

This configuration includes detailed failure messages in the HTML report, making it easier to debug test failures.

{
  "reporters": [
    "default",
    [
      "jest-html-reporter",
      {
        "includeFailureMsg": true
      }
    ]
  ]
}

Sort Results

This configuration sorts the test results in the HTML report by status, making it easier to identify failed tests.

{
  "reporters": [
    "default",
    [
      "jest-html-reporter",
      {
        "sort": "status"
      }
    ]
  ]
}

Other packages similar to jest-html-reporter

Readme

Source

jest-html-reporter

A Jest test results processor for generating a summary in HTML.
Documentation »





This plugin was inspired by karma-htmlfile-reporter


Installation

npm install jest-html-reporter --save-dev

Usage

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.

Alternative usage with package.json

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" }

Node Compatibility

This plugin is compatible with Node version ^4.8.3

Configuration

The configurations are done directly within your package.json file

PropertyTypeDescriptionDefault
pageTitleSTRINGThe title of the document. This string will also be outputted on the top of the page."Test Suite"
outputPathSTRINGThe path to where the plugin will output the HTML report. The path must include the filename and end with .html"./test-report.html"
includeFailureMsgBOOLEANIf this setting is set to true, this will output the detailed failure message for each failed test.false
styleOverridePathSTRINGThe path to a file containing CSS styles that should override the default styling.*null
*A Note on styleOverridePath

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 this repository at src/style.js) for a reference to the IDs and classes available for styling.

Example configuration (package.json)

{
	...
	"jest-html-reporter": {
		"pageTitle": "Your test suite",
		"outputPath": "test-report/index.html",
		"includeFailureMsg": false,
		"styleOverridePath": "src/teststyle.css"
	}
}

Continuous Integration

Configuration can also be performed with environment variables for dynamic file saving paths in different environments.

NOTE: Values in package.json will take precedence over environment variables.

Example

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

Configuration Environment Variables

Variable NameTypeDescriptionDefault
JEST_HTML_REPORTER_PAGE_TITLESTRINGThe title of the document. This string will also be outputted on the top of the page."Test Suite"
JEST_HTML_REPORTER_OUTPUT_PATHSTRINGThe path to where the plugin will output the HTML report. The path must include the filename and end with .html"./test-report.html"
JEST_HTML_REPORTER_INCLUDE_FAILURE_MSGBOOLEANIf this setting is set to true, this will output the detailed failure message for each failed test.false
JEST_HTML_REPORTER_STYLE_OVERRIDE_PATHSTRINGThe path to a file containing CSS styles that should override the default styling.null

Keywords

FAQs

Package last updated on 23 Jan 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc