tdd-playwright-workflow
Drive changes through TDD with unit tests and Playwright e2e tests. Use when a bug fix or feature should start with a failing reproduction, when browser workflows need e2e coverage, or when Playwright
Files2
View on GitHubSKILL.mdskills/tdd-playwright-workflow/SKILL.md
GitHubTDD Playwright Workflow
Purpose
Make implementation evidence-driven: reproduce the behavior first, make the smallest fix, then prove the user workflow works through unit and e2e tests where appropriate.
Inspect First
- existing test runners, Playwright config, browser test directories, fixtures, package scripts, CI, and user workflow docs
- changed behavior, bug reports, and product acceptance criteria
Procedure
Choose the reproduction layer.
- Unit test for pure logic, validation, formatting, reducers, and domain behavior.
- Integration test for API, database, service collaboration, or contract behavior.
- Playwright e2e for complete browser workflows such as create, edit, delete, checkout, login, or publish.
Write the failing test first.
- For bug fixes, add the failing reproduction before changing production code unless impossible.
- If impossible, document why in PR/final validation notes.
- Use
assets/templates/tdd-bug-reproduction.md.tmplfor notes.
Implement minimally.
- Make the reproduction pass.
- Avoid unrelated refactors during red/green.
- Use
typescript-monorepo-clean-codeif cleanup is needed after behavior is green.
Add or verify Playwright.
- Use existing Playwright setup when present.
- Add Playwright only when the task accepts browser e2e tooling.
- Use
assets/templates/playwright-e2e.spec.ts.tmplas a starting point. - Ensure
scripts/test-e2eexists when e2e tests are part of the repo contract. - Keep unit and e2e discovery separate. In Bun repos, do not let
bun testdiscover Playwright*.spec.tsfiles; narrowscripts/testto unit/integration paths or place Playwright files under an ignored e2e pattern. - Ignore Playwright output directories such as
test-resultsandplaywright-reportin repo linters/formatters. - Use
$click-path-and-browser-qato inventory routes, controls, accessible names, and missing lifecycle coverage before broad UI test work.
Validate the loop.
- Run the narrow failing test, then relevant broader tests.
- Use
chrome-devtools-runtime-debuggerfor runtime-only console, network, layout, or performance investigation. - Record completion evidence through
termination-gatekeeperand feature evidence throughfeature-state-machinewhen present.
Validation
- Show red/green evidence when feasible.
- Run unit and/or Playwright commands that cover the change.
- Run
./scripts/testand./scripts/validatewhen the change is broad. - After running Playwright, rerun
./scripts/testor./scripts/validateto confirm e2e output and file globs did not break baseline validation.
Completion Criteria
- Feature or bug behavior is covered at the narrowest useful layer.
- Browser lifecycle changes have Playwright or a documented reason e2e is not feasible.
- Validation evidence names exact commands and outcomes.