Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

allure-jest

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allure-jest

Allure Jest integration

  • 3.0.0-beta.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-4%
Maintainers
1
Weekly downloads
 
Created
Source

allure-jest

Allure framework integration for Jest

Allure Report logo


Warning If you are using jest@<27.0.0 use allure-jasmine package or consider to use jest-circus as a test runner with this package.

The integration doesn't work with custom runners. If you want to use the integration use jest-circus as a test runner.

Installation

Use your favorite node package manager to install the package:

npm add -D allure-jest

If you're using jest for testing node add following line to your jest.config.js file:

/** @type {import('jest').Config} */
const config = {
+  testEnvironment: "allure-jest/node",
+  testEnvironmentOptions: {
+    resultsDir: "./allure-results"
+  }
}

module.exports = config

If you're using jest for testing browser code (jsdom) add next to your jest.config.js file:

/** @type {import('jest').Config} */
const config = {
+  testEnvironment: "allure-jest/jsdom",
+  testEnvironmentOptions: {
+    resultsDir: "./allure-results"
+  }
}

module.exports = config

Use Allure runtime Api

The plugin provides custom global commands which allow to add additional info inside your tests:

import { attachment, epic, parameter } from "allure-js-commons";

it("my test", async () => {
  await attachment(currentTest.id(), screenshot, "image/png");
  await epic(currentTest.id(), "my_epic");
  await parameter(currentTest.id(), "parameter_name", "parameter_value", {
    mode: "hidden",
    excluded: false,
  });
});
import { link, issue } from "allure-js-commons";

it("basic test", async () => {
  await link("https://allurereport.org", "Allure Report"); // link with name
  await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
});

You can also configure links formatters to make usage much more convenient. %s in urlTemplate parameter will be replaced by given value.

/** @type {import('jest').Config} */
const config = {
  testEnvironment: "allure-jest/node",
  testEnvironmentOptions: {
    resultsDir: "./allure-results",
+    links: [
+      {
+        type: "issue",
+        urlTemplate: "https://example.org/issues/%s",
+        nameTemplate: "Issue: %s",
+      },
+      {
+        type: "tms",
+        urlTemplate: "https://example.org/tasks/%s"
+      },
+      {
+        type: "custom",
+        urlTemplate: "https://example.org/custom/%s"
+      },
+    ]
  }
}

module.exports = config

Then you can assign link using shorter notation:

import { issue, tms, link } from "allure-js-commons";

it("basic test", async () => {
  await issue("Issue Name", "352");
  await tms("Task Name", "352");
  await link("352", "Link name", "custom");
});

Keywords

FAQs

Package last updated on 18 Jul 2024

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc