Agent guide (humans and AI)
House style for Playwright work in this repository. Full learning path: Testing guide and hands-on labs on the course home. AI tool choice: AI testing.
Learning: open a coding agent on this repo and say which module you are on (for example, "I'm on 01") using the learn-lab-coach skill. Do not teach Codegen or an IDE Testing UI as the course path.
Maintainer QA: after changing learn/, say “dogfood the learn path” to use the learn-dogfood skill (docs walk, fresh clone setup, practice steps), or the thin prompt learn-dogfood.prompt.md on GitHub. That is not learner coaching.
Preferred tool path
- Coding agents writing or fixing tests:
npx playwright cli+ movies-playwright / playwright-cli / playwright-trace skills; traces when debugging. - Structured coverage: Playwright test agents: planner, generator, healer (thin prompts in
.github/prompts/on GitHub). - MCP: persistent explore / official agent tool loops; not required for every small edit.
- Regenerate official agents/skills after Playwright upgrades (
--loop=vscodeis definition format, not “use VS Code”):
npx playwright init-agents --loop=vscode --prompts # also: claude, copilot, codex, opencode
npx playwright init-skills --loop=agents # → .agents/skills (adds official playwright-* skills)
npx playwright init-skills --loop=claude # → .claude/skillsAfter init-skills --loop=claude: re-copy or restore the teaching skills movies-playwright, learn-lab-coach, and learn-dogfood into .claude/skills/ if the command overwrote that folder. They are not regenerated by Playwright.
Project teaching skills (keep across regenerations): movies-playwright, learn-lab-coach, learn-dogfood.
Style contract
- Locators:
getByRole,getByLabel,getByTextwith accessible names. Avoid CSS/XPath as the primary strategy. - Assertions: web-first (
toBeVisible,toHaveText,toHaveURL,toHaveCount,toMatchAriaSnapshot). - Forbidden:
waitForTimeout,force: true,waitForLoadState('networkidle'), sync.count()for waits. - List tests: import
test/expectfromtests/helpers/list-fixtures.tsand request the lightest fixture (emptyListPage→listWithMoviesPage→listPage). - Reuse
tests/helpers/list-utilities.ts(createList,addMovie,openLists,selectCoverImage, …). - Prefer helpers and list fixtures. One optional POM teaching example lives at
tests/pages/search-page.tsandtests/logged-out/lessons/pom-search.spec.ts(logged-out search only). Do not POM list flows. - Prefer
test.stepfor multi-step flows so traces stay readable. - Generated suites: tag with
@agent. Learn style frommanage-lists-*, not from dense@agentcoverage. - Seeds and plans must reference
tests/logged-in/seed.spec.tsandlist-fixtures, not deprecatedlist-test.ts. - Do not use Codegen / the test recorder as the authoring path.
Healing
- Inspect a trace or live snapshot before changing locators.
- Prefer fixing the test or app over skipping.
test.fixme()only with a comment of observed vs expected behavior when the product is wrong.
Review checklist
See the rubric in AI testing.