如何使用剧作家/测试运行程序生成 Allure HTML 报告?

Vin*_*lia 4 html allure playwright

如何使用剧作家/测试运行程序生成 Allure HTML 报告?

我们计划使用 Nodejs、Typescript 和 Playwright 推荐的测试运行程序 (playwright/test),但无法找到任何有关如何使用上述技术堆栈生成 Allure HTML 报告的文档。还有其他报告格式,例如 json 和 junit,但我们希望生成 Allure HTML 报告,并希望附加失败测试用例的屏幕截图和视频。任何参考都会非常有帮助。

Yev*_*kov 7

安装

npm i -D @playwright/test allure-playwright
Run Code Online (Sandbox Code Playgroud)

跑步

npx playwright test --reporter=line,allure-playwright
allure generate ./allure-result --clean
allure open ./allure-report
Run Code Online (Sandbox Code Playgroud)

或者

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

const config: PlaywrightTestConfig = {
  reporter: 'allure-playwright',
};
export default config;
Run Code Online (Sandbox Code Playgroud)

您可以使用ALLURE_RESULTS_DIR环境变量指定目标文件夹。例如

ALLURE_RESULTS_DIR=my-allure-results npx playwright test --reporter=line,allure-playwright
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅此处: https: //github.com/allure-framework/allure-js/blob/master/packages/allure-playwright/README.md