playwright-ts-template
AGENTS.md5 starsChanged 15 days agoMITView on GitHub
Playwright + TypeScript end-to-end test project. Tests run against https://playwright.dev by default; BASE_URL (from .env or the environment) points them at another application. The same skills live under .agents/skills/ for Cursor, Codex and Copilot. They are generated — edit the generator inputs, not the files, and run npm run skills:sync. Import through the tsconfig aliases: @fixtures/*, @pages/*, @tests/*, @helpers/*, @test-data/*. npm run lint (type-aware: @typescript-eslint/no-floating-promises fails on an un-awaited action or assertion), npm run typecheck and npm run format:check must…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,700 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository10 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/playwright-e2e.mdcCursor rule
- playwright-cliSkill
- playwright-component-testingSkill
- playwright-e2eSkill
- playwright-traceSkill
- playwright-cliSkill
- playwright-component-testingSkill
- playwright-e2eSkill
- playwright-traceSkill
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 46
Import through the tsconfig aliases: @fixtures/*, @pages/*, @tests/*, @helpers/*, @test-data/*.
- Distinctive: line 65
Every test must pass alone and in parallel with the others.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
playwright-ts-template — Agent Instructions
Project overview
Playwright + TypeScript end-to-end test project. Tests run against https://playwright.dev by default; BASE_URL (from .env or the environment) points them at another application.
Skills to load
.claude/skills/playwright-e2e/SKILL.md— how tests are planned, written, debugged and reviewed in this project (references underreferences/: shared conventions, operating workflow, delegation rules, project conventions, page-object conventions, test generation, debugging, review, fixtures and auth, locators and assertions, CI and flake triage, API testing, pass-rate analysis, agent debugging)..claude/skills/playwright-cli/SKILL.md— driving a browser and debugging a paused test withplaywright-cli..claude/skills/playwright-trace/SKILL.md— reading a trace withnpx playwright trace.
The same skills live under .agents/skills/ for Cursor, Codex and Copilot. They are generated — edit the generator inputs, not the files, and run npm run skills:sync.
Setup
nvm use
npm ci # no browsers are downloaded on install
npm run pw:setup # playwright install --with-depsCommands
npm test # all projects
npm run test:chromium # one project
npx playwright test --grep @smoke
npm run test:ui # UI mode
npx playwright test --debug=cli # pause + `playwright-cli attach …` for agents
npm run lint && npm run typecheck && npm run format:check
npm run skills:check # generated skills must be in sync (CI enforces)Structure
src/
├── fixtures/ # test-fixture.ts — `test` extended with page-object fixtures; re-exports `expect`
├── pages/ # Page Object Model classes (*.page.ts); components/ for shared pieces
├── tests/ # Specs (*.spec.ts)
├── helpers/ # Utilities
└── test-data/ # Static test dataImport through the tsconfig aliases: @fixtures/*, @pages/*, @tests/*, @helpers/*, @test-data/*.
Conventions
Page objects
- One class per page in
src/pages/{name}.page.ts; locators asreadonlyfields set in the constructor. - Actions wrapped in
test.step(); assertion helpers prefixedexpect…. - Navigation through
page.goto('/relative')—baseURLcomes from the config.
Locators (in order of preference)
getByRole()2.getByLabel()3.getByPlaceholder()/getByText()4.getByTestId()(data-testid) 5. CSS only as a last resort — never XPath.
Tests
- Specs import
testandexpectfrom@fixtures/test-fixture, never from@playwright/test; page objects arrive as fixtures (async ({ homePage }) => …), so specs never callnewand keep no describe-scoped variables. Page objects themselves importtestfrom@playwright/testfortest.step()(importing the fixtures file there would be a cycle). src/tests/{feature}.spec.ts;test.describe('Feature', { tag: ['@smoke'] }, …)— tags are options, not title suffixes.- Web-first assertions only (
await expect(locator).toBeVisible()); nowaitForTimeout(), no{ force: true }, notest.only(CI forbids it). - Every test must pass alone and in parallel with the others; no shared mutable state between tests.
- Retries and traces are CI-only (
retries: 2,trace: 'on-first-retry'); a test that only passes on retry is a bug.
Quality gates
npm run lint (type-aware: @typescript-eslint/no-floating-promises fails on an un-awaited action or assertion), npm run typecheck and npm run format:check must pass; CI runs them together with skills:check and a check that the Dockerfile's Playwright image tag equals the installed @playwright/test version, plus a docker job that builds the image and runs the suite inside it (make docker-test). Bumping @playwright/test means bumping the Dockerfile tag and digest and re-running npm run skills:sync.
Dependency updates
Dependabot opens weekly PRs (npm, GitHub Actions, Docker). .npmrc sets ignore-scripts=true and engine-strict=true, so lifecycle scripts never run on install and the Node floor in engines is enforced. A Dependabot PR that bumps @playwright/test fails the Dockerfile tag check and skills:check on purpose: in that PR, bump the Dockerfile tag and digest to the same version, run npm run skills:sync, and commit the regenerated skills so the reviewer sees the instruction diff. A bump of wico-playwright-agent-skills needs the same skills:sync + commit step.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

