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): Promise<void>

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 }) => { await 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): Promise<void>

Set the test's owner.

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

Tag

  • allure.tag(tag: string): Promise<void>
  • allure.tags(...values: string[]): Promise<void>

Set the test's tags.

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

Severity

  • allure.severity(severity: string): Promise<void>

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 }) => { await allure.severity(Severity.CRITICAL); // ... });

Label

  • allure.label(label: string, value: string): Promise<void>
  • allure.labels(...values: Label[]): Promise<void>

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

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

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

ID

  • allure.id(id: string): Promise<void>

Set the test's ID.

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

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 }) => { await allure.link("Related Documentation", "https://example.com/docs"); await allure.issue("AUTH-123", "https://example.com/issues/AUTH-123"); await allure.tms("TMS-456", "https://example.com/tms/TMS-456"); // ... });

Behavior-based hierarchy

  • allure.epic(epic: string): Promise<void>
  • allure.feature(epic: string): Promise<void>
  • allure.story(story: string): Promise<void>

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

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; test("Some test", async ({ page }) => { await allure.epic("Web interface"); await allure.feature("Essential features"); await allure.story("Authentication"); // ... });

Suite-based hierarchy

  • allure.parentSuite(name: string): Promise<void>
  • allure.suite(name: string): Promise<void>
  • allure.subSuite(name: string): Promise<void>

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

TypeScript
import { test } from "@playwright/test"; import { allure } from "allure-playwright"; test("Some test", async ({ page }) => { await allure.parentSuite("Tests for web interface"); await allure.suite("Tests for essential features"); await allure.subSuite("Tests for authentication"); // ... });

Parametrized tests

  • allure.parameter(name: string, value: string, options?: ParameterOptions): Promise<void>

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 }) => { await allure.parameter("login", login); await 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.