🚀 快速安装

复制以下命令并运行,立即安装此 Skill:

npx skills add https://skills.sh/alirezarezvani/claude-skills/report

💡 提示:需要 Node.js 和 NPM

智能测试报告 (Smart Test Reporting)

生成能够融入用户现有工作流的测试报告。零新工具。

步骤 (Steps)

1. 运行测试(如果尚未运行)(Run Tests – If Not Already Run)

检查最近的测试结果是否存在:

ls -la test-results/ playwright-report/ 2>/dev/null

如果没有最近的结果,运行测试:

npx playwright test --reporter=json,html,list 2>&1 | tee test-output.log

2. 解析结果 (Parse Results)

读取 JSON 报告:

npx playwright test --reporter=json 2> /dev/null

提取:

  • 总测试数、通过数、失败数、跳过数、不稳定数 (Total tests, passed, failed, skipped, flaky)
  • 每个测试的耗时和总耗时 (Duration per test and total)
  • 失败的测试名称及错误信息 (Failed test names with error messages)
  • 不稳定的测试(重试后通过)(Flaky tests – passed on retry)

3. 检测报告目标 (Detect Report Destination)

检查已配置的内容并自动路由:

检查项 (Check) 如果找到 (If found) 操作 (Action)
TESTRAIL_URL 环境变量 (env var) TestRail 已配置 (TestRail configured) 通过 /pw:testrail push 推送结果 (Push results via /pw:testrail push)
SLACK_WEBHOOK_URL 环境变量 (env var) Slack 已配置 (Slack configured) 向 Slack 发送摘要 (Post summary to Slack)
.github/workflows/ GitHub Actions 结果通过工件发送到 PR 评论 (Results go to PR comment via artifacts)
playwright-report/ HTML 报告器 (HTML reporter) 打开或提供报告 (Open or serve the report)
以上均无 (None of the above) 默认 (Default) 生成 Markdown 报告 (Generate markdown report)

4. 生成报告 (Generate Report)

Markdown 报告(始终生成)(Markdown Report – Always Generated)

# 测试结果 — {{日期}} (Test Results — {{date}})

## 摘要 (Summary)
- ✅ 通过 (Passed): {{passed}}
- ❌ 失败 (Failed): {{failed}}
- ⏭️ 跳过 (Skipped): {{skipped}}
- 🔄 不稳定 (Flaky): {{flaky}}
- ⏱️ 耗时 (Duration): {{duration}}

## 失败的测试 (Failed Tests)
| 测试 (Test) | 错误 (Error) | 文件 (File) |
|-------|-------|-------|
| {{名称 (name)}} | {{错误 (error)}} | {{文件}}:{{行}} ({{file}}:{{line}}) |

## 不稳定的测试 (Flaky Tests)
| 测试 (Test) | 重试次数 (Retries) | 文件 (File) |
|-------|-------|-------|
| {{名称 (name)}} | {{重试次数 (retries)}} | {{文件 (file)}} |

## 按项目 (By Project)
| 浏览器 (Browser) | 通过 (Passed) | 失败 (Failed) | 耗时 (Duration) |
|---------|-------|-------|----------|
| Chromium | X | Y | Zs |
| Firefox | X | Y | Zs |
| WebKit | X | Y | Zs |

保存到 test-reports/{{date}}-report.md

Slack 摘要(如果配置了 Webhook)(Slack Summary – If Webhook Configured)

curl -X POST "$SLACK_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "🧪 测试结果:✅ {{passed}} | ❌ {{failed}} | ⏱️ {{duration}}\n{{失败详情 (failed_details)}}"
  }'

TestRail 推送(如果已配置)(TestRail Push – If Configured)

使用 JSON 结果调用 /pw:testrail push

HTML 报告 (HTML Report)

npx playwright show-report

或者在 CI 中:

echo "HTML 报告可在以下位置查看:playwright-report/index.html (HTML report available at: playwright-report/index.html)"

5. 趋势分析(如果存在历史数据)(Trend Analysis – If Historical Data Exists)

如果 test-reports/ 中存在之前的报告:

  • 比较一段时间内的通过率 (Compare pass rate over time)
  • 识别最近变得不稳定的测试 (Identify tests that became flaky recently)
  • 突出显示新故障与重复故障 (Highlight new failures vs. recurring failures)

输出 (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)

📄 原始文档

完整文档(英文):

https://skills.sh/alirezarezvani/claude-skills/report

💡 提示:点击上方链接查看 skills.sh 原始英文文档,方便对照翻译。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。