LLM to Playwright
This proof of concept lets an LLM enrich acceptance criteria and convert them into Playwright test code. It demonstrates a robust selector strategy, a11y scanning, and data-driven execution in a compact package.
Highlights
- Prioritizes
data-testid
selectors with ARIA / role-based fallbacks as documented guidelines. - Auto-generates sample tests under
tests/generated/
including snapshots and accessibility rules. - Loops through data files (JSON / CSV) to produce multiple cases, keeping maintenance to simple data edits.
Key Artifacts
- tests/generated/ — Auto-generated Playwright suites.
- tests/README.md — Notes on selectors, snapshots, and a11y policy.
- blueprint.sample.json — Sample source data enriched by the LLM.
- scripts/generate-tests.mjs — Driver script orchestrating LLM calls and code generation.
How to Reproduce
- In
projects/02-blueprint-to-playwright/
, runnpm install
to fetch dependencies. - Execute
npm run generate
(sample configuration) to regenerate the Playwright suites. - Run
npx playwright test
to execute generated tests with accessibility and snapshot checks.
Next Steps
- Extend
blueprint.sample.json
with more acceptance criteria to control LLM breadth. - Automate diff reviews in GitHub Actions and surface changes in the weekly summary.
- Harden secrets management and integrate
playwright test --update-snapshots
into CI before production use.