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:
Ullrich Schäfer 2026-03-25 00:44:28 +01:00
parent a09f41e03d
commit 6d8e570afc
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9

View file

@ -186,24 +186,25 @@ jobs:
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);
const s = r.stats;
const dur = (s.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 += '| :white_check_mark: Passed | ' + s.expected + ' |\n';
if (s.unexpected > 0) md += '| :x: Failed | ' + s.unexpected + ' |\n';
if (s.flaky > 0) md += '| :warning: Flaky | ' + s.flaky + ' |\n';
if (s.skipped > 0) md += '| :fast_forward: Skipped | ' + s.skipped + ' |\n';
md += '| :stopwatch: Duration | ' + dur + 's |\n\n';
for (const file of r.suites) {
for (const describe of (file.suites || [])) {
md += '### ' + describe.title + '\n\n';
for (const spec of (describe.specs || [])) {
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);
"