Loading repository data…
Loading repository data…
jay-yeluru / repository
A hands-on guide to using Playwright's AI-powered Planner, Generator, and Healer agents to autonomously create, run, and self-heal tests using MCP (Model Context Protocol).
A hands-on guide to using Playwright's AI-powered Planner, Generator, and Healer agents to automatically generate, run, and fix tests for the TodoMVC app.
Think of Playwright Agents as your AI testing assistants. Instead of writing tests manually, you describe what you want to test, and the agents handle the rest.
| Agent | Role | Input | Output |
|---|---|---|---|
| 🎭 Planner | Explorer | Requirements | Human-readable roadmap (.md) |
| 🎭 Generator | Builder | Roadmap | Executable test code (.spec.ts) |
| 🎭 Healer | Maintainer | Broken Test | Automatic patch and fix |
graph LR
A[Requirement] --> B(🎭 Planner)
B --> C[specs/plan.md]
C --> D(🎭 Generator)
D --> E[tests/demo.spec.ts]
E --> F{Run Test}
F -- Fail --> G(🎭 Healer)
G --> H[Fixed Code]
F -- Pass --> I[Success]
# Clone and install
git clone <your-repo-url>
cd playwright-agents-ts
npm install
# Initialize Agents (Choose your AI tool loop)
# For VS Code:
npx playwright init-agents --loop=vscode
# For Claude Code:
npx playwright init-agents --loop=claude
Ensure your agents can talk to the browser via MCP (Model Context Protocol).
/.github/agents/ (Auto-generated)/.vscode/mcp.json[!TIP] Your
mcp.jsonshould look like this for the agents to run correctly:{ "servers": { "playwright-test": { "type": "stdio", "command": "npx", "args": ["playwright", "run-test-mcp-server"] } } }
The "Seed" test tells agents how to access your app. See tests/seed.spec.ts.
In your AI tool, ask the Planner Agent:
"Create a test plan for the TodoMVC app covering: Adding, marking complete, filtering, and deleting todos. Reference: tests/seed.spec.ts"
Ask the Generator Agent:
"Generate Playwright tests for all scenarios in specs/todomvc-plan.md. Reference: tests/seed.spec.ts"
npm test'1 item left' to '99 items')."Fix the failing test: tests/.spec.ts"
├── .github/agents/ # AI Agent instructions
├── specs/ # Markdown test plans (Planner output)
├── tests/ # Executable test files (Generator output)
├── pages/ # Page Object Models (Encapsulated logic)
├── fixtures/ # Custom test context/setup
└── playwright.config # Global Playwright settings
| Command | Description |
|---|---|
npm test | Run all tests (Headless) |
npm run test:headed | Run tests with browser visible |
npm run test:ui | Open Playwright UI Mode |
npm run report | View detailed HTML report |
getByRole, getByText).MIT