report

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Smart Test Reporting

智能测试报告

Generate test reports that plug into the user's existing workflow. Zero new tools.
生成可融入用户现有工作流的测试报告,无需新增任何工具。

Steps

步骤

1. Run Tests (If Not Already Run)

1. 运行测试(若尚未运行)

Check if recent test results exist:
bash
ls -la test-results/ playwright-report/ 2>/dev/null
If no recent results, run tests:
bash
npx playwright test --reporter=json,html,list 2>&1 | tee test-output.log
检查是否存在近期测试结果:
bash
ls -la test-results/ playwright-report/ 2>/dev/null
若不存在近期结果,则运行测试:
bash
npx playwright test --reporter=json,html,list 2>&1 | tee test-output.log

2. Parse Results

2. 解析结果

Read the JSON report:
bash
npx playwright test --reporter=json 2> /dev/null
Extract:
  • Total tests, passed, failed, skipped, flaky
  • Duration per test and total
  • Failed test names with error messages
  • Flaky tests (passed on retry)
读取JSON报告:
bash
npx playwright test --reporter=json 2> /dev/null
提取以下信息:
  • 测试总数、通过数、失败数、跳过数、不稳定数
  • 单测试耗时与总耗时
  • 失败测试名称及错误信息
  • 不稳定测试(重试后通过的测试)

3. Detect Report Destination

3. 检测报告目标位置

Check what's configured and route automatically:
CheckIf foundAction
TESTRAIL_URL
env var
TestRail configuredPush results via
/pw:testrail push
SLACK_WEBHOOK_URL
env var
Slack configuredPost summary to Slack
.github/workflows/
GitHub ActionsResults go to PR comment via artifacts
playwright-report/
HTML reporterOpen or serve the report
None of the aboveDefaultGenerate markdown report
检查已配置项并自动路由:
检查项如果已配置操作
TESTRAIL_URL
环境变量
已配置TestRail通过
/pw:testrail push
推送结果
SLACK_WEBHOOK_URL
环境变量
已配置Slack向Slack发送结果汇总
.github/workflows/
已配置GitHub Actions通过工件将结果发送至PR评论
playwright-report/
已生成HTML报告打开或托管该报告
以上均不满足默认情况生成Markdown报告

4. Generate Report

4. 生成报告

Markdown Report (Always Generated)

Markdown报告(始终生成)

markdown
undefined
markdown
undefined

Test Results — {{date}}

测试结果 — {{date}}

Summary

汇总

  • ✅ Passed: {{passed}}
  • ❌ Failed: {{failed}}
  • ⏭️ Skipped: {{skipped}}
  • 🔄 Flaky: {{flaky}}
  • ⏱️ Duration: {{duration}}
  • ✅ 通过:{{passed}}
  • ❌ 失败:{{failed}}
  • ⏭️ 跳过:{{skipped}}
  • 🔄 不稳定:{{flaky}}
  • ⏱️ 总耗时:{{duration}}

Failed Tests

失败测试详情

TestErrorFile
{{name}}{{error}}{{file}}:{{line}}
测试用例错误信息文件位置
{{name}}{{error}}{{file}}:{{line}}

Flaky Tests

不稳定测试

TestRetriesFile
{{name}}{{retries}}{{file}}
测试用例重试次数文件位置
{{name}}{{retries}}{{file}}

By Project

按项目统计

BrowserPassedFailedDuration
ChromiumXYZs
FirefoxXYZs
WebKitXYZs

Save to `test-reports/{{date}}-report.md`.
浏览器通过数失败数耗时
ChromiumXYZ秒
FirefoxXYZ秒
WebKitXYZ秒

保存至 `test-reports/{{date}}-report.md`。

Slack Summary (If Webhook Configured)

Slack汇总(若已配置Webhook)

bash
curl -X POST "$SLACK_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "🧪 Test Results: ✅ {{passed}} | ❌ {{failed}} | ⏱️ {{duration}}\n{{failed_details}}"
  }'
bash
curl -X POST "$SLACK_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "🧪 测试结果:✅ {{passed}} | ❌ {{failed}} | ⏱️ {{duration}}\n{{failed_details}}"
  }'

TestRail Push (If Configured)

推送至TestRail(若已配置)

Invoke
/pw:testrail push
with the JSON results.
调用
/pw:testrail push
并传入JSON格式的测试结果。

HTML Report

HTML报告

bash
npx playwright show-report
Or if in CI:
bash
echo "HTML report available at: playwright-report/index.html"
bash
npx playwright show-report
若在CI环境中:
bash
echo "HTML报告地址:playwright-report/index.html"

5. Trend Analysis (If Historical Data Exists)

5. 趋势分析(若存在历史数据)

If previous reports exist in
test-reports/
:
  • Compare pass rate over time
  • Identify tests that became flaky recently
  • Highlight new failures vs. recurring failures
test-reports/
目录下存在过往报告:
  • 对比不同时间段的通过率
  • 识别近期变为不稳定的测试用例
  • 突出新出现的失败与重复出现的失败

Output

输出内容

  • Summary with pass/fail/skip/flaky counts
  • Failed test details with error messages
  • Report destination confirmation
  • Trend comparison (if historical data available)
  • Next action recommendation (fix failures or celebrate green)
  • 包含通过/失败/跳过/不稳定数量的汇总信息
  • 带有错误信息的失败测试详情
  • 报告目标位置确认
  • 趋势对比(若有历史数据)
  • 下一步操作建议(修复失败测试或庆祝全通过)