Allure Reporter for Jest

2.3.0 · active · verified Sun Apr 19

jest-allure2-reporter is an idiomatic Jest reporter that integrates with the Allure Framework, enabling the generation of rich, interactive test reports. It is currently at version 2.3.0 and actively maintained with a regular release cadence, including frequent bug fixes and feature updates (e.g., support for Jest 30). Key differentiators include its ability to visualize detailed test execution flows with step-by-step breakdowns, attach various artifacts (screenshots, logs, JSON data) to tests, and provide comprehensive test metadata through both programmatic APIs and JSDocblock pragmas. The library offers robust TypeScript support and features like the `@Step` decorator for defining test steps and capabilities for visual regression testing, providing a more detailed and debuggable testing experience compared to standard Jest reporters.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure jest-allure2-reporter in `jest.config.js`, define test steps using the `@Step` decorator, add attachments and metadata with the `allure` API, and generate the final Allure report.

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

/* my-page.ts */
import { allure, Step } from 'jest-allure2-reporter/api';

export class MyPage {
  @Step('Load user data for ID: {{userId}}')
  async loadUserData(userId: string) {
    const userData = { name: 'John Doe', id: userId };
    allure.attachment('User Data', JSON.stringify(userData, null, 2), 'application/json');
    return userData;
  }
}

/* my.test.ts */
import { allure } from 'jest-allure2-reporter/api';
import { MyPage } from './my-page';

describe('User Profile', () => {
  const page = new MyPage();

  it('should load user data correctly', async () => {
    allure.feature('Profile');
    allure.severity('critical');
    const userData = await page.loadUserData('user123');
    expect(userData.name).toBe('John Doe');
  });
});

// To generate and open reports after tests:
// npm install -g allure-commandline
// allure generate allure-results --clean
// allure open

view raw JSON →