report

TotalClaw 作者 totalclaw

生成测试报告。当用户说“测试报告”、“结果摘要”时使用 “测试状态”、“显示结果”、“测试仪表板”或“测试进展如何”。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~playwright-pro-report
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~playwright-pro-report/file -o playwright-pro-report.md
# 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)

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
```

### 2. Parse Results

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)

### 3. Detect Report Destination

Check what's configured and route automatically:

| Check | If found | Action |
|---|---|---|
| `TESTRAIL_URL` env var | TestRail configured | Push results via `/pw:testrail push` |
| `SLACK_WEBHOOK_URL` env var | Slack configured | Post summary to Slack |
| `.github/workflows/` | GitHub Actions | Results go to PR comment via artifacts |
| `playwright-report/` | HTML reporter | Open or serve the report |
| None of the above | Default | Generate markdown report |

### 4. Generate Report

#### Markdown Report (Always Generated)

```markdown
# 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 |
```

Save to `test-reports/{{date}}-report.md`.

#### Slack Summary (If Webhook Configured)

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

#### TestRail Push (If Configured)

Invoke `/pw:testrail push` with the JSON results.

#### HTML Report

```bash
npx playwright show-report
```

Or if in CI:
```bash
echo "HTML report available at: playwright-report/index.html"
```

### 5. Trend Analysis (If Historical Data Exists)

If previous reports exist in `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)

---

## 中文说明

# Smart Test Reporting(智能测试报告)

生成可接入用户现有工作流的测试报告。无需任何新工具。

## Steps(步骤)

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

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

```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(解析结果)

读取 JSON 报告:

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

提取:
- 总测试数、通过、失败、跳过、不稳定(flaky)
- 每个测试及总耗时
- 失败测试名称及错误信息
- 不稳定测试(重试后通过)

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

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

| 检查 | 若找到 | 操作 |
|---|---|---|
| `TESTRAIL_URL` 环境变量 | 已配置 TestRail | 通过 `/pw:testrail push` 推送结果 |
| `SLACK_WEBHOOK_URL` 环境变量 | 已配置 Slack | 将摘要发布到 Slack |
| `.github/workflows/` | GitHub Actions | 结果通过 artifacts 进入 PR 评论 |
| `playwright-report/` | HTML reporter | 打开或托管该报告 |
| 以上均无 | 默认 | 生成 markdown 报告 |

### 4. Generate Report(生成报告)

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

```markdown
# 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 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}}"
  }'
```

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

用 JSON 结果调用 `/pw:testrail push`。

#### HTML Report(HTML 报告)

```bash
npx playwright show-report
```

或在 CI 中:
```bash
echo "HTML report available at: playwright-report/index.html"
```

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

如果 `test-reports/` 中存在以往报告:
- 比较通过率随时间的变化
- 识别近期变得不稳定的测试
- 突出显示新失败与反复出现的失败

## Output(输出)

- 含通过/失败/跳过/不稳定计数的摘要
- 失败测试的详情及错误信息
- 报告目标确认
- 趋势比较(如有历史数据)
- 下一步行动建议(修复失败或庆祝全绿)