{"slug":"playwright-evidence","title":"playwright-evidence","summary":"Use when capturing E2E test evidence for a frontend story: the success screenshots recorded in the story's evidence log (the only evidence kept with the test plan), plus local-only failure diagnostics (videos, traces, reports). Covers Playwright setup, screenshot capture and reco","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-11-29T00:42:32.852466Z","repo":{"url":"https://github.com/SebastienDegodez/skraft-plugin","stars":17,"forks":3,"license":"GPL-3.0","updatedAt":"2026-11-29T00:18:21Z"},"bodyHtml":"<hr>\n<h2>name: playwright-evidence\ndescription: &gt;\nUse when capturing E2E test evidence for a frontend story: the success screenshots\nrecorded in the story's evidence log (the only evidence kept with the test plan), plus\nlocal-only failure diagnostics (videos, traces, reports). Covers Playwright setup,\nscreenshot capture and recording, on-failure capture and trace collection.</h2>\n<h1>Playwright Evidence Skill</h1>\n<h2>Overview</h2>\n<p>For frontend stories, the engineer records the success screenshots in the story's evidence\ndirectory (<code>.copilot-tracking/skraft-plans/{projectSlug}/evidence/{date}/{story}/screenshots/</code>,\nlisted by the <code>evidence.screenshots</code> gate of its log). With the test plan, they are the evidence\nthe QA reads; nothing else is kept as evidence. Failure diagnostics (videos, traces, HTML and JUnit\nreports) stay in Playwright's own <code>test-results/</code> and <code>playwright-report/</code> folders, local-only.\nUse the resolved tracking root and return actual repository-root-relative paths;\nnever infer today's directory or read pipeline state. Backend-only work does not\nload browser capture.</p>\n<pre><code>Approved real E2E run → Engineer captures   → evidence.screenshots → Reviewed report refs\n                       mandatory success     hashed in the v7 log   remote URLs or\n                       + failure proof       (Git-ignored)          explicit local-only\n</code></pre>\n<p><code>{story}</code> is the story slug passed as <code>SKRAFT_STORY_ID</code> env var (e.g. <code>42-add-eligibility-check</code>).\nUse returned plan and evidence refs, not legacy phase-path conventions.</p>\n<p><strong>Scope:</strong> capture, name and record screenshots. The engineer owns capture and recording; the\nevidence log lists them, so no manifest is written; the router consumes refs only. For report media selection load\n<code>qa-reporting</code>, then its\n<a href=\"references/report-contract.md#media-boundary\">reporting contract</a>. No hosting or\nautomatic upload/push. Existing remote URLs must be verified; local paths are\nlocal-only, never published attachments. Upload mechanism and consent require\nseparate agreement; warn that traces/screenshots may expose private data.</p>\n<h2>Docker Dependency Freshness (MANDATORY)</h2>\n<p>Before running ANY e2e verification — first run or re-run after a fix — rebuild and restart every\nDocker Compose / Testcontainers dependency the suite talks to (<code>docker compose down &amp;&amp; docker compose up -d --build</code>, or the equivalent Testcontainers container recreation). Do NOT reuse a container left\nrunning from a previous session or a previous story.</p>\n<p><strong>Why:</strong> a stale container silently passes tests against yesterday's image — the suite is green but\nproves nothing about the current code. This exact failure mode (e2e passing against an out-of-date\ndependency container) reached DELIVER undetected on a prior epic and was only caught by a manual\nrework pass. Treat it as a checklist item, not an optional troubleshooting step:</p>\n<ol>\n<li>Tear down existing dependency containers for this story before the FIRST test run of the session.</li>\n<li>Rebuild images (<code>--build</code> / equivalent) so local code/config changes are actually picked up.</li>\n<li>Re-run the full e2e suite after every dependency rebuild — a partial re-run against a mixed\nold/new environment is worse than no run, since it produces a false-positive green.</li>\n<li>Say it in the change log (e.g. <code>containers: rebuilt</code>) so reviewers can see freshness was\nverified, not assumed.</li>\n</ol>\n<h2>Playwright Setup (TypeScript)</h2>\n<p>Install dependencies:</p>\n<pre><code>npm install -D @playwright/test\nnpx playwright install --with-deps chromium\n</code></pre>\n<p>Configure via <code>playwright.config.ts</code> at project root. Reference <code>references/playwright-ts-setup.md</code>\nfor full configuration options, parallel settings, and browser lifecycle management.</p>\n<h2>Screenshot Capture</h2>\n<p>Screenshots are mandatory for a frontend story: one whose commits touch a <code>@visual</code>\nscenario, <code>tests/e2e/</code>, a <code>package.json</code> declaring <code>react</code> or a <code>playwright.config.*</code>.\nCapture at least one success screenshot per delivered journey at its asserted outcome,\nduring the real E2E run of the story, and name it after the scenario it shows. Record each PNG\nwith the stack adapter's <code>gate-log.mjs --log {evidence dir}/qg-{story}.json --screenshot &lt;png&gt;</code>\n(on .NET, <code>qg-collect.mjs --screenshot &lt;png&gt;</code>): it copies the PNG into the story's evidence\ndirectory (ignored by Git, never committed) and records it in the <code>evidence.screenshots</code> gate of\nthe v7 log (<code>quality-gates-evidence-contract</code>) with the sha256 of its bytes. A frontend story\nwithout a screenshot fails <code>qg-verify</code>.\nScreenshot alone never proves correctness. Do not rerun tests for report cosmetics.</p>\n<p>Success-selection and report <code>maxMedia</code> limits never truncate correctness-gate\ncaptures, failure diagnostics or reviewer inputs. Retain full local evidence.</p>\n<p>Wire an <code>afterEach</code> hook to capture on failure:</p>\n<pre><code>import { test, expect } from '@playwright/test';\n\ntest.afterEach(async ({ page }, testInfo) =&gt; {\n  if (testInfo.status !== testInfo.expectedStatus) {\n    const screenshotPath = `evidence/screenshots/${testInfo.title.replace(/\\s+/g, '-')}-${Date.now()}.png`;\n    await page.screenshot({ path: screenshotPath, fullPage: true });\n    testInfo.attachments.push({ name: 'screenshot', path: screenshotPath, contentType: 'image/png' });\n  }\n});\n</code></pre>\n<p>Naming convention: <code>{test-title}-{timestamp}.png</code>, under Playwright's <code>test-results/</code>: a\nfailure screenshot is a local diagnostic, never recorded as evidence.\nUsing <code>testInfo.attachments</code> makes the screenshot appear inline in the HTML report.\nReference <code>references/screenshot-and-video.md</code> for all <code>page.screenshot()</code> options and\non-failure hook patterns.</p>\n<h2>Video Recording</h2>\n<p>Set <code>video: 'retain-on-failure'</code> in <code>playwright.config.ts</code>:</p>\n<pre><code>use: {\n  video: { mode: 'retain-on-failure', size: { width: 1280, height: 720 } },\n}\n</code></pre>\n<p>CLI override: <code>npx playwright test --video=retain-on-failure</code></p>\n<p>Keep Playwright's default <code>outputDir</code> (<code>test-results/</code>): videos and traces are local\ndiagnostics, never evidence.\nNo manual context management required — the test runner handles lifecycle.\nReference <code>references/screenshot-and-video.md</code> for all video config options.</p>\n<h2>Trace Files</h2>\n<p>Set <code>trace: 'retain-on-failure'</code> in <code>playwright.config.ts</code> for automatic capture:</p>\n<pre><code>use: {\n  trace: 'retain-on-failure',\n}\n</code></pre>\n<p>CLI: <code>npx playwright test --trace=on</code> to capture traces for all tests.</p>\n<p>For manual control within a test:</p>\n<pre><code>await context.tracing.start({ screenshots: true, snapshots: true, sources: true });\n// ... test steps ...\nawait context.tracing.stop({ path: 'test-results/traces/trace.zip' });\n</code></pre>\n<p>View a trace locally: <code>npx playwright show-trace test-results/traces/trace.zip</code></p>\n<p>Traces contain DOM snapshots, network requests, console logs, and source context. Prefer traces\nover screenshots when diagnosing flaky tests. Reference <code>references/trace-viewer.md</code> for all options.</p>\n<h2>Test Report Generation</h2>\n<p>Configure multi-reporter output in <code>playwright.config.ts</code>:</p>\n<pre><code>reporter: [\n  ['html', { outputFolder: 'playwright-report' }],\n  ['junit', { outputFile: 'playwright-report/results.xml' }],\n],\n</code></pre>\n<p>CLI equivalents:</p>\n<pre><code>npx playwright test --reporter=html\nnpx playwright test --reporter=junit\nnpx playwright show-report\n</code></pre>\n<p>Retain HTML/JUnit locally. Existing approved CI may expose artifacts/status checks;\nwithout a verified remote URL, report them as local-only. Do not add uploads or\nchange CI solely to publish a report.</p>\n<h2>CI Configuration</h2>\n<p>Only when CI setup/upload is separately authorized, adapt the existing job:</p>\n<ol>\n<li><code>actions/setup-node@v4</code> with Node 20</li>\n<li><code>npm ci</code></li>\n<li><code>npx playwright install --with-deps chromium</code> (cache <code>~/.cache/ms-playwright</code>)</li>\n<li><code>npx playwright test --reporter=html,junit</code></li>\n<li><code>actions/upload-artifact@v4</code> — upload <code>playwright-report/</code> and <code>test-results/</code> on failure</li>\n</ol>\n<p>Recording a screenshot never authorizes a binary upload.\nReference <code>references/ci-configuration.md</code> for the full workflow YAML.</p>\n<h2>Evidence Retention Policy</h2>\n<p>Add to <code>.gitignore</code>:</p>\n<pre><code>.copilot-tracking/skraft-plans/*/evidence/\nplaywright-report/\ntest-results/\n</code></pre>\n<p>Preserve full local failure evidence and correctness proof; publication selection\nnever deletes it, nor any screenshot the <code>evidence.screenshots</code> gate cites. CI retention follows separately approved\npolicy; neither report <code>maxMedia</code> nor missing upload consent limits local proof.</p>\n<h2>References</h2>\n<ul>\n<li><code>references/playwright-ts-setup.md</code> — npm install, CLI, <code>playwright.config.ts</code>, parallel settings</li>\n<li><code>references/screenshot-and-video.md</code> — <code>page.screenshot()</code> options, video recording, on-failure hooks</li>\n<li><code>references/trace-viewer.md</code> — tracing config, <code>context.tracing</code> API, trace viewer CLI</li>\n<li><code>references/ci-configuration.md</code> — full GitHub Actions workflow YAML, caching, secrets</li>\n</ul>\n<h2>Examples</h2>\n<ul>\n<li><code>examples/01-basic-screenshot.md</code> — <code>afterEach</code> on-failure screenshot with eligibility test</li>\n<li><code>examples/02-video-on-failure.md</code> — <code>retain-on-failure</code> video config, accessing video path</li>\n<li><code>examples/03-trace-upload.md</code> — manual trace capture with all options, stop and save</li>\n</ul>\n","files":[{"path":"examples/01-basic-screenshot.md","sizeBytes":2340,"isText":true},{"path":"examples/02-video-on-failure.md","sizeBytes":2601,"isText":true},{"path":"examples/03-trace-upload.md","sizeBytes":3418,"isText":true},{"path":"references/ci-configuration.md","sizeBytes":6219,"isText":true},{"path":"references/mcp-publication.md","sizeBytes":15558,"isText":true},{"path":"references/playwright-ts-setup.md","sizeBytes":4472,"isText":true},{"path":"references/report-contract.md","sizeBytes":7094,"isText":true},{"path":"references/screenshot-and-video.md","sizeBytes":4371,"isText":true},{"path":"references/trace-viewer.md","sizeBytes":4684,"isText":true},{"path":"SKILL.md","sizeBytes":9051,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-11-29T00:44:21.062598Z","sha256":"55489187A80765613D04DC6860CD04B78AD11C2BCCDB80220D4A476F453C70E1","sizeBytes":25040},"review":null,"source":{"repositoryUrl":"https://github.com/SebastienDegodez/skraft-plugin","path":"plugins/skraft-framework/skills/playwright-evidence","license":"GPL-3.0","commit":"c6117c6236a25490bf1916b131866069740c9b22","subtreeSha":"7702A0E1CD73044C71C6F7B293296701164CDC0DB58726EE8B3A755A5266D98E","lastSyncedAt":"2026-11-29T00:42:27.348488Z"},"reviewedAt":"2026-11-29T00:48:16.042594Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/SebastienDegodez/skraft-plugin/tree/main/plugins/skraft-framework/skills/playwright-evidence"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install sebastiendegodez-skraft-plugin@llmmart"},{"target":"git","command":"git clone https://github.com/SebastienDegodez/skraft-plugin.git"}]}