Allure Playwright reference

These are the functions that you can use to integrate your Playwright tests with Allure. The examples are written in TypeScript, but all the functions can be used in JavaScript projects as well.

Note that while standard features require importing the test object from Playwright, the additional features also require importing the allure object from Allure Playwright.

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; test("Some test", async ({ page }, testInfo) => { // ... });

Metadata

Assign a test's description, links and other metadata.

Description

  • allure.description(value: string)

Set the test's description. Markdown formatting is allowed. Any HTML formatting, if present, will be stripped for security purposes.

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; test("Some test", async ({ page }) => { allure.description( "This test attempts to log into the website using a login and a password. Fails if any error happens.\n\nNote that this test does not test 2-Factor Authentication.", ); // ... });

Owner

  • allure.owner(owner: string)

Set the test's owner.

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; test("Some test", async ({ page }) => { allure.owner("John Doe"); // ... });

Tag

  • allure.tag(tag: string)
  • allure.tags(...values: string[])

Set the test's tags.

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; test("Some test", async ({ page }) => { allure.tags("NewUI", "Essentials", "Authentication"); // ... });

Severity

  • allure.severity(severity: string)

Set the test's severity.

The value must be a constant from the Severity class.

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; import { Severity } from "allure-js-commons"; test("Some test", async ({ page }) => { allure.severity(Severity.CRITICAL); // ... });

Label

  • allure.label(label: string, value: string)
  • allure.labels(...values: Label[])

Set an arbitrary label for the test. This is the underlying implementation for a lot of Allure's other functions.

The name of the label can be a constant from the LabelName class or any other string.

You can call the function multiple times to create an array of values under that name.

TypeScript
import { test } from "@playwright/test"; import { allure, LabelName } from "allure-playwright"; test("Some test", async ({ page }) => { allure.label(LabelName.LANGUAGE, "typescript"); allure.label(LabelName.FRAMEWORK, "playwright"); // ... });

ID

  • allure.id(id: string)

Set the test's ID.

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; test("Some test", async ({ page }) => { allure.id(123); // ... });
  • allure.link(url: string, name?: string, type?: string)
  • allure.links(...values: Link[])

Add a link related to the test.

The name will be used as the link's text. If it is omitted, the full URL will be used instead.

The type affects the icon that is displayed next to the link in the test report. For convenience, Allure provides two shorthand functions with pre-selected link types: issue() and tms().

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; test("Some test", async ({ page }) => { allure.link("Related Documentation", "https://example.com/docs"); allure.issue("AUTH-123", "https://example.com/issues/AUTH-123"); allure.tms("TMS-456", "https://example.com/tms/TMS-456"); // ... });

Issue

  • allure.issue(name: string, url: string)

Add a link to an issue in a bug tracker related to the test.

This is a shorthand for link() with the "issue" type.

TMS

  • allure.tms(name: string, url: string)

Add a link to an issue in a bug tracker related to the test.

This is a shorthand for link() with the "tms" type.

Behavior-based hierarchy

  • allure.epic(epic: string)
  • allure.feature(epic: string)
  • allure.story(story: string)

Assign names of epics, features or user stories for a test, as part of Allure's behavior-based hierarchy.

Suite-based hierarchy

  • allure.parentSuite(name: string)
  • allure.suite(name: string)
  • allure.subSuite(name: string)

Assign names of parent suite, suite or sub-suite for a test, as part of Allure's suite-based hierarchy.

Parametrized tests

  • allure.parameter(name: string, value: string, options?: ParameterOptions)

Specify a name and value of a parameter that was used during this test. See Parametrized tests for more details.

The options argument, if given, must be an object with two optional properties excluded and mode.

  • If excluded is set to true, Allure will not use the parameter when comparing the current test result with previous one in the history. This argument is only used by Allure TestOps.

  • The mode affects how the parameter will be displayed in the report. Available options are:

    • "default" (same as not specifying any mode) — the parameter and its value will be shown in a table along with other parameters.
    • "masked" — the parameter will be shown in the table, but its value will be hidden. Use this mode for passwords, tokens and other sensitive parameters.
    • "hidden" — the parameter and its value will not be shown in the test report. Note, however, that it is still possible to extract the value from the allure_results directory if you publish it.
TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; for (const login of ["johndoe", "[email protected]"]) { test("Test Authentication", async ({ page }) => { allure.parameter("login", login); allure.parameter("auth_method", "password"); // ... }); }
Powered by
logo

Join our newsletter

Join our community

We aim to make Allure Report as reliable and user-friendly as possible, and together with the community, we're here to help when problems arise.

© 2024 Qameta Software Inc. All rights reserved.