Fix Playwright job summary: handle nested suite structure
Playwright JSON has file → describe → specs nesting. Use stats.expected/unexpected for counts, iterate nested suites. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a09f41e03d
commit
6d8e570afc
1 changed files with 16 additions and 15 deletions
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
|
|
@ -186,24 +186,25 @@ jobs:
|
||||||
if [ -f playwright-results.json ]; then
|
if [ -f playwright-results.json ]; then
|
||||||
node -e "
|
node -e "
|
||||||
const r = require('./playwright-results.json');
|
const r = require('./playwright-results.json');
|
||||||
const total = r.suites.reduce((n, s) => n + s.specs.length, 0);
|
const s = r.stats;
|
||||||
const passed = r.suites.reduce((n, s) => n + s.specs.filter(t => t.ok).length, 0);
|
const dur = (s.duration / 1000).toFixed(1);
|
||||||
const failed = total - passed;
|
|
||||||
const dur = (r.stats.duration / 1000).toFixed(1);
|
|
||||||
let md = '## Playwright E2E Results\n\n';
|
let md = '## Playwright E2E Results\n\n';
|
||||||
md += '| Status | Count |\n|--------|-------|\n';
|
md += '| Status | Count |\n|--------|-------|\n';
|
||||||
md += '| :white_check_mark: Passed | ${passed} |\n';
|
md += '| :white_check_mark: Passed | ' + s.expected + ' |\n';
|
||||||
if (failed > 0) md += '| :x: Failed | ${failed} |\n';
|
if (s.unexpected > 0) md += '| :x: Failed | ' + s.unexpected + ' |\n';
|
||||||
md += '| Total | ${total} |\n';
|
if (s.flaky > 0) md += '| :warning: Flaky | ' + s.flaky + ' |\n';
|
||||||
md += '| Duration | ${dur}s |\n\n';
|
if (s.skipped > 0) md += '| :fast_forward: Skipped | ' + s.skipped + ' |\n';
|
||||||
for (const suite of r.suites) {
|
md += '| :stopwatch: Duration | ' + dur + 's |\n\n';
|
||||||
md += '### ' + suite.title + '\n\n';
|
for (const file of r.suites) {
|
||||||
for (const spec of suite.specs) {
|
for (const describe of (file.suites || [])) {
|
||||||
const icon = spec.ok ? ':white_check_mark:' : ':x:';
|
md += '### ' + describe.title + '\n\n';
|
||||||
const time = spec.tests?.[0]?.results?.[0]?.duration;
|
for (const spec of (describe.specs || [])) {
|
||||||
md += '- ' + icon + ' ' + spec.title + (time ? ' (' + time + 'ms)' : '') + '\n';
|
const icon = spec.ok ? ':white_check_mark:' : ':x:';
|
||||||
|
const t = spec.tests?.[0]?.results?.[0]?.duration;
|
||||||
|
md += '- ' + icon + ' ' + spec.title + (t ? ' (' + t + 'ms)' : '') + '\n';
|
||||||
|
}
|
||||||
|
md += '\n';
|
||||||
}
|
}
|
||||||
md += '\n';
|
|
||||||
}
|
}
|
||||||
require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, md);
|
require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, md);
|
||||||
"
|
"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue