Jest Circus Allure Environment

raw JSON →
1.1.1 verified Fri May 01 auth: no javascript

Jest test environment (v1.1.1, last updated June 2021) that integrates Allure reporting with Jest Circus test runner. Generates Allure result files for rich test reports. Key differentiator: enables Allure annotations via JSDoc pragmas directly in test files. Requires Allure CLI to serve reports. Ships TypeScript types. Maintained by community, low release cadence. Alternative to allure-jest.

error Cannot find module 'jest-circus-allure-environment' from 'jest.config.js'
cause Package not installed or testEnvironment path incorrect.
fix
Run 'npm install --save-dev jest-circus-allure-environment' and ensure testEnvironment string is correct.
error TypeError: jestCircusAllureEnvironment is not a constructor
cause Importing named export instead of setting testEnvironment string.
fix
Use 'testEnvironment: "jest-circus-allure-environment"' in config, do not import directly.
error Allure .json files not generated after tests
cause Allure environment not loaded or testRunner not set.
fix
Ensure testEnvironment and testRunner are set in jest.config.js as shown in quickstart.
error allure: command not found
cause Allure CLI not installed.
fix
Install Allure CLI (Java): see https://docs.qameta.io/allure-report/#_installing_a_commandline
breaking In v1.0.0, environment option 'categoryDefinitions' renamed to 'categories'.
fix Rename 'categoryDefinitions' to 'categories' in jest.config.js environmentOptions.
deprecated Old v0.x behavior for 'testPath' config option is default in v1.x.
fix No action needed; just leave 'testPath' if you want per-test results.
gotcha Must use 'jest-circus/runner' as testRunner, not default Jasmine runner.
fix Set testRunner: 'jest-circus/runner' in jest.config.js.
gotcha Allure CLI (Java) required to generate HTML report; node module does not serve reports.
fix Install Allure CLI and run 'allure serve ./allure-results'.
gotcha Docblock pragmas must be inside the test function body, not outside.
fix Place /** @tag foo */ inside the callback function of test() or describe().
npm install jest-circus-allure-environment
yarn add jest-circus-allure-environment
pnpm add jest-circus-allure-environment

Configures Jest with Allure environment, sets up type augmentation, uses JSDoc pragma in test.

// jest.config.js
module.exports = {
  testEnvironment: 'jest-circus-allure-environment',
  testRunner: 'jest-circus/runner',
}

// jest.setup.js
import 'jest-circus-allure-environment'

// some.test.js
test('example', () => {
  /**
   * @severity critical
   * @tag smoke
   */
  expect(true).toBe(true)
})

// Run: npx jest
// Generate report: allure serve ./allure-results