Registry / testing / jest-allure2-reporter

jest-allure2-reporter

JSON →
library2.3.0jsnpmunverified

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.

npm install jest-allure2-reporter
INSTALL
IMPORT
SIG · JEST-ALLURE2-REPOR
J
jest-allure2-reporter
testingjavascriptv2.3.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jest-allure2-reporter
✓ // jest.config.js module.exports = { reporters: [ 'default', 'jest-allure2-reporter' ] };
✗ import { AllureReporter } from 'jest-allure2-reporter';
The reporter is configured as a string in Jest's `reporters` array, not directly imported.
environment-node
✓ // jest.config.js module.exports = { testEnvironment: 'jest-allure2-reporter/environment-node' };
✗ import { NodeEnvironment } from 'jest-allure2-reporter/environment-node';
The test environment is specified as a string path in Jest configuration. Use `environment-jsdom` for browser tests.
allure
✓ import { allure } from 'jest-allure2-reporter/api';
✗ import allure from 'jest-allure2-reporter';
The `allure` object for programmatic API access (e.g., adding steps, attachments, metadata) must be imported from the specific `api` subpath.
Step
✓ import { Step } from 'jest-allure2-reporter/api';
✗ import { Step } from 'jest-allure2-reporter';
The `@Step` decorator, like the `allure` object, is exported from the `api` subpath for use in test files.

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
Debug
Known issues
gotchaThe Allure command line tool (`allure-commandline`) is a separate dependency and must be installed globally or locally to generate and serve reports after tests complete. This package only generates the raw Allure results.
fix
Install globally: `npm install -g allure-commandline` or `yarn global add allure-commandline`.
affects: >=1.0.0
breakingOlder versions of Jest (below 27.2.5) are not supported. This reporter requires Jest 27.2.5 or higher. Compatibility fixes for Jest 30 were introduced in v2.2.1.
fix
Ensure your Jest version meets the peer dependency requirement (`jest@>=27.2.5`). Upgrade `jest` to at least `27.2.5`, preferably the latest stable version compatible with `jest-allure2-reporter`.
affects: <2.2.1
gotchaIf using TypeScript decorators like `@Step`, ensure `experimentalDecorators` and `emitDecoratorMetadata` are enabled in your `tsconfig.json`.
fix
Add `"experimentalDecorators": true, "emitDecoratorMetadata": true` to your `compilerOptions` in `tsconfig.json`.
affects: >=1.0.0
gotchaThe `testEnvironment` must be explicitly set to either `jest-allure2-reporter/environment-node` (for Node.js tests) or `jest-allure2-reporter/environment-jsdom` (for browser-like tests). Failing to do so will result in Allure APIs not being available in your tests.
fix
Update your `jest.config.js` to include: `testEnvironment: 'jest-allure2-reporter/environment-node'` (or `.../environment-jsdom`).
affects: >=1.0.0
breakingNode.js versions older than 16.20.0 are not supported by the package. Running on unsupported Node.js versions may lead to unexpected errors or failures.
fix
Upgrade your Node.js environment to version 16.20.0 or higher.
affects: <=2.3.0
Errors
Common errors & fixes
Error: Jest: a reporter 'jest-allure2-reporter' cannot be found.
The reporter string 'jest-allure2-reporter' is not resolvable by Jest, likely because the package is not installed or incorrectly referenced.
fix
Ensure `jest-allure2-reporter` is installed (`npm install --save-dev jest-allure2-reporter`) and correctly listed in `jest.config.js` reporters array.
ReferenceError: allure is not defined
The `allure` object or `@Step` decorator is not available in the global scope or imported incorrectly, often due to an incorrect `testEnvironment` setting.
fix
Verify `jest.config.js` includes `testEnvironment: 'jest-allure2-reporter/environment-node'` (or `.../environment-jsdom`) and that `allure` or `Step` are imported from `'jest-allure2-reporter/api'`.
Cannot find name 'allure'. Did you mean 'URL'?
When using TypeScript, the types for the `allure` object might not be correctly picked up by the compiler.
fix
Ensure you have imported `allure` from `'jest-allure2-reporter/api'` in your TypeScript files. Also, verify your `tsconfig.json` correctly includes `node_modules/@types` or relevant type declarations.
Error: Allure commandline is not installed. Please install it globally `npm install -g allure-commandline`
The `allure generate` or `allure open` commands are not found because the Allure CLI tool is not installed or not in the system's PATH.
fix
Install the Allure command line tool globally: `npm install -g allure-commandline`.
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
jestrequiredRequired peer dependency for Jest test runner.
jest-docblockrequiredPeer dependency for processing JSDocblock pragmas in test files.
Agent activity
6 hits · last 30 days
node
6
Resources