Skip to content

Installation and Usage

Johan Hargne edited this page Feb 20, 2018 · 8 revisions

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

Run as a Custom Reporter

It is also possible to run jest-html-reporter as a custom reporter within Jest. This allows the plugin to be run in parallel with Jest instead of after a test run, and will guarantee that the test report is generated even if Jest is run with options such as --forceExit.

Add the following entry to the Jest config (jest.config.js):

"reporters": ["default", "./node_modules/jest-html-reporter"]

Please note that you need to add the "executionMode": "reporter" configuration within jesthtmlreporter.config.json in order for this to work. Find out more about this at the configuration section.


Node Compatibility

This plugin is compatible with Node version ^4.8.3

Clone this wiki locally