You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP →
Socket
Socket
Sign inDemoInstall

jest-allure-circus

Package Overview
Dependencies
11
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-allure-circus

[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%


Version published
Maintainers
1
Created

Readme

Source

Jest Allure Circus

jest XO code style semantic-release License: MIT

Allure reporting for newest Jest Circus v28.1

Allure Report



❗️ Requirements

ResourceDescription
JestA delightful JavaScript testing framework.
Allure 2 CLI"A Java jar command line tool that turns Allure result files into beautiful Allure reports."

:rocket: Quick start

  1. Add this package
yarn add --dev jest-circus-allure
  1. Update jest.config.js

See the testEnvironment docs for configuration details.

{
  "testEnvironment": "jest-circus-allure",
  "testRunner": "jest-circus/runner"
}

OR use this at the top of your testEnv file

const AllureEnvironment = require('jest-allure-circus').default
  1. Run tests
yarn test
  1. Open the Allure report
allure serve ./allure-results

:camera_flash: Allure reporting in your tests

To provide more information in your reports you can use Docblock pragmas within your tests. For types support you'll need some additional configuration.

// simple.test.js

test('2 + 3 is 5', () => {
  /** My test description.
   * @epic Implement addition functionality
   * @tag Accounting
   */

  expect(2 + 3).toBe(5)
})

🔧 Typescript & Intellisense setup

  1. Support Typescript & intellisense by loading the module into your jest.setup.js file
// jest.setup.js

import 'jest-circus-allure-environment' // Typescript or ESM
require('jest-circus-allure-environment') // CommonJS
  1. Make sure your jest.setup.js file is properly configured.

See the setupFilesAfterEnv docs for configuration details.

// jest.config.js

{
  "setupFilesAfterEnv": ["./jest.setup.js"]
}

:gear: Options

Options that can be passed into the environmentOptions property of your jest.config.js

ParameterDescriptionDefault
resultsDirPath where Allure result files will be written."allure-results"
jiraUrlURL to Jira instance. Any @issue docblock pragmas will link to this URL.undefined
tmsUrlURL to TMS instance. Any @tms docblock pragmas will link to this URL.undefined
environmentInfoKey value pairs that will appear under the environment section of the Allure report{}
categoriesArray of custom categories you wish to see in the Allure report. See an example[]
testPathPath to your test files. This path will be subtracted from the Allure report when organizing tests into suites.Jest.config.rootDir

📈 DocBlocks

You may set code comments inside your tests called DocBlocks, that can be parsed for specific allure report pragmas. These are the supported DocBlock pragmas you may add to a test.

🔍 Descriptions

Add descriptions that document the tested functionality.

test('does something important, when triggered by user', () => {
  /** This uses a 3rd party API that typically undergoes maintenance on Tuesdays.
   */

  ...
})

🏷 Tag

Tag a test with a custom label.

Set multiple tags using a , deliminator.

test('does something important, when triggered by user', () => {
  /**
   * @tag beta
   * @tag feature-flagged, api-v3
   */

  ...
})

👥 Owner

Set an owner for a test.

test('does something important, when triggered by user', () => {
  /**
   * @owner ios-team
   */

  ..
})

:part_alternation_mark: Severity

Mark tests with a severity rating to indicate the importance of the tested functionality in respect to the overall application.

LevelDescription
blockerTests that if failing, will halt further development.
criticalTests that must pass; or risk disrupting crucial application logic.
normal (default)Tests that are of average importance to the overall application.
minorTests that if failing, should only effect a small subset of the application.
trivialTests that validate unreleased, disabled, or deprecated features.

Example of setting a test as "critical" severity

test('does something important, when triggered by user', () => {
  /**
   * @severity critical
   */

  ...
})

📇 Behaviors (epics, features, stories)

Mark tests with a behavior label to organize tests in a feature based hierarchy.

LevelDescription
epicTests that if fail, will effect the expected functionality of an epic.
featureTests that if fail, will effect the expected functionality of a feature.
storyTests that if fail, will effect the expected functionality of story.

Example:

test('validation message appears, when email field is skipped', () => {
  /**
   * @epic Automate user sign up
   * @feature Registration page
   * @story Validate required registration fields before creating new user
   */

  ...
})

Add Jira and TMS links to a test.

LevelDescription
issueAdds a link to the test report that will open an existing issue in Jira.
tmsAdds a link to the test report that will open an existing test case in your test management system.

Example:

test('validation message appears, when email field is skipped', () => {
  /**
   * @issue DEBT-60
   * @tms CORE-122
   */

  ...
})

:bug: AllureId

Test Case ID in Allure.

Example:

test('validation message appears, when email field is skipped', () => {
  /**
   * @allureId 92066
   */

  ...
})

👩‍🎓 Advanced

🎛 Global Allure API

An instance of the allure runtime will be available on the Node global variable. You can utilize it's APIs to provide custom reporting functionality.

/**
 * Returns the Allure test instance for the currently running test.
 */
allure.currentTest(): AllureTest;

/**
 * Adds a description to the report of the current test. Supports markdown.
 */
allure.description(markdown: string): void;

/**
 * Starts and returns a new step instance on the current executable.
 */
allure.startStep(name: string): StepWrapper;

/**
 * Starts a new Allure step, sets the status, and adds any provided attachments (optional), then ends the step.
 */
allure.logStep(
  name: string,
  status: Status,
  attachments?: Array<{ name: string; content: string; type: ContentType }>
): void;

/**
 * Add a parameter to the report of the current executable.
 */
allure.parameter(name: string, value: string): void;

/**
 * Attach a file to the report of the current executable.
 */
allure.attachment(
  name: string,
  content: Buffer | string,
  type: ContentType
);

/**
 * Add a issue link to the report of the current test.
 */
allure.issue(id: string): void;

/**
 * Add a TMS link to the report of the current test.
 */
allure.tms(id: string): void;

/**
 * Add a severity label to the report of the current test.
 */
allure.severity(severity: Severity): void;

/**
 * Add a epic label to the report of the current test.
 */
allure.epic(epic: string): void;

/**
 * Add a feature label to the report of the current test.
 */
allure.feature(feature: string): void;

/**
 * Add a story label to the report of the current test.
 */
allure.story(story: string): void;

/**
 * Add a tag label to the report of the current test.
 */
allure.tag(name: string): void;

/**
 * Add a custom label to the report of the current test.
 */
allure.label(name: string, value: string): void;

/**
 * Add Test Case ID in Allure.
 */
allure.allureId(id: string, index?: number): void;

Keywords

FAQs

Package last updated on 28 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc