Add Playwright job summary to CI
Generates a markdown summary table in GitHub Actions showing passed/failed tests with timing per test. Uses the JSON reporter to output results, then a Node script to format as markdown and append to $GITHUB_STEP_SUMMARY. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
19ce2d1f1e
commit
074bcff4e5
3 changed files with 33 additions and 1 deletions
29
.github/workflows/ci.yml
vendored
29
.github/workflows/ci.yml
vendored
|
|
@ -180,6 +180,35 @@ jobs:
|
|||
env:
|
||||
BROUTER_URL: http://localhost:17777
|
||||
|
||||
- name: Playwright job summary
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
if [ -f playwright-results.json ]; then
|
||||
node -e "
|
||||
const r = require('./playwright-results.json');
|
||||
const total = r.suites.reduce((n, s) => n + s.specs.length, 0);
|
||||
const passed = r.suites.reduce((n, s) => n + s.specs.filter(t => t.ok).length, 0);
|
||||
const failed = total - passed;
|
||||
const dur = (r.stats.duration / 1000).toFixed(1);
|
||||
let md = '## Playwright E2E Results\n\n';
|
||||
md += '| Status | Count |\n|--------|-------|\n';
|
||||
md += '| :white_check_mark: Passed | ${passed} |\n';
|
||||
if (failed > 0) md += '| :x: Failed | ${failed} |\n';
|
||||
md += '| Total | ${total} |\n';
|
||||
md += '| Duration | ${dur}s |\n\n';
|
||||
for (const suite of r.suites) {
|
||||
md += '### ' + suite.title + '\n\n';
|
||||
for (const spec of suite.specs) {
|
||||
const icon = spec.ok ? ':white_check_mark:' : ':x:';
|
||||
const time = spec.tests?.[0]?.results?.[0]?.duration;
|
||||
md += '- ' + icon + ' ' + spec.title + (time ? ' (' + time + 'ms)' : '') + '\n';
|
||||
}
|
||||
md += '\n';
|
||||
}
|
||||
require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, md);
|
||||
"
|
||||
fi
|
||||
|
||||
- uses: actions/upload-artifact@v7
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -11,3 +11,4 @@ dist/
|
|||
e2e/results/
|
||||
test-results/
|
||||
playwright-report/
|
||||
playwright-results.json
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ export default defineConfig({
|
|||
fullyParallel: true,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
reporter: process.env.CI ? [["github"], ["html", { open: "never" }]] : "list",
|
||||
reporter: process.env.CI
|
||||
? [["github"], ["html", { open: "never" }], ["json", { outputFile: "playwright-results.json" }]]
|
||||
: "list",
|
||||
use: {
|
||||
baseURL: "http://localhost:3000",
|
||||
trace: "on-first-retry",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue