How to generate Allure HTML report using playwright/test runner?

Viewed 3278

How to generate Allure HTML report using playwright/test runner?

We are planning to use Nodejs, Typescript and Playwright recommended test runner (playwright/test) but wasn't able to find any documentation regarding how to generate Allure HTML report using the mentioned technology stack. There are other report formats like json and junit but we would like to generate Allure HTML report and like to attach screenshots and videos for failed test cases. Any references would be really helpful.

2 Answers

Install

npm i -D @playwright/test allure-playwright

Run

npx playwright test --reporter=line,allure-playwright
allure generate ./allure-result --clean
allure open ./allure-report

or

// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  reporter: 'allure-playwright',
};
export default config;

You can specify target folder using ALLURE_RESULTS_DIR environment variable. e.g.

ALLURE_RESULTS_DIR=my-allure-results npx playwright test --reporter=line,allure-playwright

For more information, see here: https://github.com/allure-framework/allure-js/blob/master/packages/allure-playwright/README.md

This is old answer which is no longer valid and I am unable to Delete it.As now there is direct support between Playwright- test and allure reporting.

Even though it doesn't answer your question directly but if you are willing to move to Jasmine to use allure reporting then read below with a ready to use solution.

Able to generate allure reports succesfully with playwright using Jasmine with jasmine-allure-reporter without any issues with screenshots.

Related