Skip to main content

Installation

Prerequisites

Jest

To use jest-allure2-reporter in your project, you have to be using jest as your test runner. The minimum supported version is 27.x.

tip

Use Jest's default jest-circus runner for the full reporting functionality. Reports generated with any other runners like jest-jasmine will be incomplete and contain only the most essential information.

Allure CLI

In the most cases, you'd like to serve or generate HTML reports from the generated JSON files in allure-results directory.

To do so, make sure you have allure-commandline installed:

$ allure --version
2.29.0
If you don't have Allure CLI installed

First of all, make sure you have Java 17 or later installed on your machine:

java -version
# openjdk version "17.0.1" 2024-01-16
# OpenJDK Runtime Environment (build 17.0.10+0)

If you can't install recent Java version, you can try using older Allure CLI versions.

To install Allure CLI globally, run:

npm install -g allure-commandline

To install Allure CLI locally (per project), run:

npm install --save-dev allure-commandline

However, if you generate the HTML reports elsewhere, you can skip this step.

Setup

Use your package manager to add jest-allure2-reporter to the project:

npm install --save-dev jest-allure2-reporter

Edit your Jest configuration file this way:

jest.config.js
 /** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
// …
testEnvironment: 'jest-allure2-reporter/environment-node',
reporters: [
'default',
'jest-allure2-reporter',
],
// …
};

At this point, you are ready to run your tests with the reporter.