Skip to content

Latest commit

 

History

History
130 lines (98 loc) · 4.74 KB

README.md

File metadata and controls

130 lines (98 loc) · 4.74 KB

allure-playwright

Allure framework integration for Playwright Test framework

Allure Report logo


Installation

Use your favorite node package manager to install the package:

npm i -D allure-playwright

Usage

Add allure-playwright as the reporter in the Playwright configuration file:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: "allure-playwright",
});

Or, if you want to use more than one reporter:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: [["line"], ["allure-playwright"]],
});

Or pass the same values via the command line:

npx playwright test --reporter=line,allure-playwright

When the test run completes, the result files will be generated in the ./allure-results directory. If you want to use another location, provide it via the resultsDir reporter option (see below).

View the report

Note

You need Allure Report to generate and open the report from the result files. See the installation instructions for more details.

Generate Allure Report:

allure generate ./allure-results -o ./allure-report

Open Allure Report:

allure open ./allure-report

The documentation

Learn more about Allure Playwright from the official documentation at https://allurereport.org/docs/playwright/.

Allure Playwright options

Use following options to configure Allure Playwright:

Option Description Default
resultsDir The path of the results folder. ./allure-results
detail Hide the pw:api and hooks steps in report. true
suiteTitle Use test title instead of allure.suite(). true
links Allure Runtime API link templates. undefined
environmentInfo A set of key-value pairs to display in the Environment section of the report undefined
categories An array of category definitions, each describing a category of defects undefined

Here is an example of the reporter configuration:

import { defineConfig } from '@playwright/test';
import os from "node:os";

export default defineConfig({
  reporter: [
    [
      "allure-playwright",
      {
        detail: true,
        resultsDir: "my-allure-results",
        suiteTitle: false,
        links: {
          link: {
            urlTemplate: "https://github.com/allure-framework/allure-js/blob/main/%s",
          },
          issue: {
            urlTemplate: "https://github.com/allure-framework/allure-js/issues/%s",
            nameTemplate: "ISSUE-%s",
          },
        },
        environmentInfo: {
          OS: os.platform(),
          Architecture: os.arch(),
          NodeVersion: process.version,
        },
        categories: [
          {
            name: "Missing file errors",
            messageRegex: /^ENOENT: no such file or directory/,
          },
        ],
      },
    ],
  ],
});

More details about Allure Playwright configuration are available at https://allurereport.org/docs/playwright-configuration/.