Playwright Test Agents: Planner, Generator and Healer Explained
What the Playwright planner, generator and healer do, what init-agents writes on version 1.65.1, and a tested review guard that catches a healer rewriting an assertion or skipping a test.
Hely PatelHead of Product and Marketing17 min read
Playwright test agents are three AI agent definitions that Playwright installs into your project: a planner that explores your app and writes a Markdown test plan, a generator that turns the plan into Playwright tests, and a healer that replays failing tests and patches them. They run inside an assistant such as Claude Code or GitHub Copilot in VS Code, and they produce Node.js test code.
The healer is the stage that needs a rule: it is rewarded for a passing run, and a passing run can hide a product defect. This guide explains each agent, shows what setup writes on Playwright 1.65.1, and includes a tested guard script that flags a healer patch that changes an assertion or skips a test.
Who this is for: automation engineers and SDETs on Playwright who want to know what the agents do, whether to adopt them and how to keep them honest. Not for: teams automating in Python or Java, because the agents generate Node.js Playwright Test code.
What are Playwright test agents?
Playwright introduced test agents in version 1.56. The documentation describes three that can run independently, in sequence or as steps in an agentic loop. Run in sequence they produce test coverage for a product.
Agent
Input
Output
Job
Planner
A goal, plus a seed test, optionally a product requirements document
specs/*.md test plan
Explores the app and writes scenarios with steps and expected results
Generator
The Markdown plan
tests/*.spec.ts
Writes tests and verifies selectors and assertions live as it performs each scenario
Healer
The name of a failing test
A patched test, or a skipped test
Replays the failure, inspects the page, patches and reruns until it passes or guardrails stop it
The documentation says the healer's outcome is either a passing test or a skipped test when it believes the functionality is broken. That second outcome matters later in this post.
The agents are not a pytest tool and not a general browser agent. They generate Playwright Test code in TypeScript or JavaScript, which is a real constraint for teams that automate in other languages.
How do you set up Playwright test agents?
Setup is one command with a --loop option naming the assistant. The documentation lists VS Code, Claude Code, Codex and OpenCode, and notes that VS Code needs version 1.105 or later for the agentic experience to work properly. Running npx playwright init-agents --help on 1.65.1 shows six values: claude, codex, copilot, opencode, vscode and vscode-legacy, plus options for --config, --project and --prompts.
For Claude Code, the command writes:
File
Purpose
.claude/agents/playwright-test-planner.md
Planner definition
.claude/agents/playwright-test-generator.md
Generator definition
.claude/agents/playwright-test-healer.md
Healer definition
.mcp.json
Registers a playwright-test MCP server started with npx playwright run-test-mcp-server
seed.spec.ts
Starter test the planner uses to learn your setup
specs/README.md
A folder for plans
With --loop=vscode, the same three definitions land as .github/agents/*.agent.md, alongside .vscode/mcp.json, a .github/workflows/copilot-setup-steps.yml, the seed and the specs folder.
The definitions are small: in our run the generator was 3,401 bytes, the healer 2,942 and the planner 2,880, and the MCP file 156 bytes. Read them before you use them. They are generic, so they know nothing about your app, your naming rules or your team's standards.
Why you should not edit the agent files
The documentation says to regenerate the definitions whenever Playwright updates, and to treat them as generated files. We tested what that means. We edited an agent definition and ran init-agents again: the edit was lost. Re-running overwrote the definition files and left edits to seed.spec.ts and existing files under specs/ alone.
Put standing rules where they survive: in AGENTS.md or CLAUDE.md and in lint configuration, as set out in the guide to coding agents for testers. Commit the generated files so an update shows up as a reviewable diff.
What is a seed test and how do you write a good one?
The seed test is the most important file you control. The documentation says the planner runs it to execute "all the initialization necessary for your test", including global setup, dependencies, fixtures and hooks, and that both the planner and the generator use it as the reference for setup and for the structure of generated tests. A weak seed gives you weak tests.
Starts in a known state. Logs in, loads fixtures, sets feature flags.
Proves the page loaded, with a meaningful assertion (here, the heading) and not only a navigation.
Uses your real fixtures and page objects, so generated tests follow the same structure as hand-written ones.
Stays small. It is a template for setup, not a test of a feature.
How does the Playwright planner work, and how do you review its Markdown test plan?
You ask for a plan for a scenario or flow, include the seed in context and optionally add a product requirements document. The planner explores the app through the browser and writes a Markdown plan. The documented shape is a title, an application overview, numbered scenario groups with a **Seed:** line, and numbered scenarios with steps and expected results.
A plan excerpt, written by hand in that format for the shop app (it is not planner output):
### 3. Coupons
**Seed:** `tests/seed.spec.ts`
#### 3.1 SAVE10 takes 10 percent off
**Steps:**
1. Add "Trail Backpack" to the cart
2. Enter SAVE10 in the coupon field and apply it
**Expected Results:** status reads "Coupon applied" and the total is 720.00
Review the plan before generating any code. A plan is cheaper to correct than a suite, and its expected results are where wrong assumptions enter. The planner can learn a total of 720.00 only from the page or from your instructions, so that is the line a person confirms.
A plan review checklist
Check
Question
Source of expected results
Does each expected value come from a requirement, not from what the page currently shows?
Boundaries
Are limits and thresholds covered below, on and above?
Negative paths
Are invalid inputs and error messages in the plan?
Independence
Can each scenario run without the others?
Setup
Does each scenario name its seed, and does the seed cover its preconditions?
Gaps
Which flows from the requirement are missing?
What does the generator produce?
The generator reads the plan and writes test files with header comments linking the plan and the seed, for example // spec: specs/cart.md and // seed: tests/seed.spec.ts. Its definition tells it to run each step in the browser while writing, so locators come from the real page. The documentation adds that you can supply generation hints and an assertion catalog, and that tests should map one-to-one to plan scenarios where feasible. It also warns that generated tests may include initial errors, which the healer can fix.
Generated tests still need the usual review: web-first assertions, no fixed waits, independent tests and meaningful names. A linter catches most of these, which is why the guide to coding agents for testers pairs agent files with ESLint rules. Scripts that fall outside the Playwright agent flow can be drafted with Test Automation Genius and held to the same review.
What does the Playwright healer agent do, and why does it need a gate?
The documentation says the healer runs the suite, replays failing steps, inspects the current UI for equivalent elements or flows, suggests a patch such as a locator update, wait adjustment or data fix, and reruns. The generated definition goes further. It tells the healer to fix "assertions and expected values", to mark a test test.fixme() when it is confident the test is correct, and not to ask the user questions but to "do the most reasonable thing possible to pass the test".
That last instruction is the risk in one line. A healer optimises for a passing run, and a passing run is not the same as a correct product. A locator change that fixes a renamed button is healing. A changed expected value that makes a failing assertion pass hides a defect.
An experiment: one app release, three possible healer patches
We built a small shop page and four Playwright tests plus the seed. Version 1 renders a button labelled "Add to cart" and applies a 10 percent coupon. Version 2 is a release with two changes: the button is renamed "Add to basket", and the coupon discount is accidentally 1 percent instead of 10. A script builds a temporary git repository, replays the release and applies three patches in turn.
== baseline (shop v1)
5 passed (1.7s)
== after the app release, before any healing
✘ 1 tests/cart.spec.ts:11:3 › Cart and coupon › Add a product to the cart (8.0s)
✘ 2 tests/cart.spec.ts:18:3 › Cart and coupon › Shipping is free from Rs 500 (8.0s)
✘ 3 tests/cart.spec.ts:25:3 › Cart and coupon › Apply the SAVE10 coupon (8.0s)
✘ 4 tests/cart.spec.ts:34:3 › Cart and coupon › Reject an unknown coupon (8.0s)
✓ 5 tests/seed.spec.ts:4:3 › Test group › seed (207ms)
4 failed
1 passed (35.3s)
== patch A: locator only
✓ 1 tests/cart.spec.ts:11:3 › Cart and coupon › Add a product to the cart (236ms)
✓ 2 tests/cart.spec.ts:18:3 › Cart and coupon › Shipping is free from Rs 500 (164ms)
✘ 3 tests/cart.spec.ts:25:3 › Cart and coupon › Apply the SAVE10 coupon (2.2s)
✓ 4 tests/cart.spec.ts:34:3 › Cart and coupon › Reject an unknown coupon (243ms)
✓ 5 tests/seed.spec.ts:4:3 › Test group › seed (123ms)
Error: expect(locator).toHaveText(expected) failed
1 failed
4 passed (4.4s)
-- guard:
OK 2 changed lines, none touch assertions, skips, waits or matchers
== patch B: locator and expected total
✓ 1 tests/cart.spec.ts:11:3 › Cart and coupon › Add a product to the cart (201ms)
✓ 2 tests/cart.spec.ts:18:3 › Cart and coupon › Shipping is free from Rs 500 (172ms)
✓ 3 tests/cart.spec.ts:25:3 › Cart and coupon › Apply the SAVE10 coupon (185ms)
✓ 4 tests/cart.spec.ts:34:3 › Cart and coupon › Reject an unknown coupon (219ms)
✓ 5 tests/seed.spec.ts:4:3 › Test group › seed (138ms)
5 passed (1.8s)
-- guard:
REVIEW assertion removed or changed (the healer may have rewritten what correct means):
- await expect(page.locator('#total')).toHaveText('720.00');
== patch C: locator and test.fixme
✓ 1 tests/cart.spec.ts:11:3 › Cart and coupon › Add a product to the cart (209ms)
✓ 2 tests/cart.spec.ts:18:3 › Cart and coupon › Shipping is free from Rs 500 (153ms)
✓ 4 tests/cart.spec.ts:34:3 › Cart and coupon › Reject an unknown coupon (198ms)
✓ 5 tests/seed.spec.ts:4:3 › Test group › seed (115ms)
1 skipped
4 passed (1.5s)
-- guard:
REVIEW test skipped (check that it is not hiding a product defect):
+ test.fixme('Apply the SAVE10 coupon', async ({ page }) => {
Step
Result
Baseline on version 1
5 passed
After the release, before healing
4 failed, 1 passed. All four cart tests fail on the renamed button
Patch A: locator only
4 passed, 1 failed. The coupon test fails with expected 720.00 and received 792.00
Patch B: locator and expected total changed to 792.00
5 passed. The defect is hidden
Patch C: locator and test.fixme on the coupon test
4 passed, 1 skipped. The defect is parked
Patch A is the healer working correctly: it repairs the locator, leaves the assertion alone, and the suite surfaces a real defect, since a customer would pay 792.00 instead of 720.00. Patch B reaches a fully green run by agreeing with the bug. Patch C reaches a mostly green run by hiding the one failing test, and its "1 skipped" line is easy to miss in a long log.
The guard: a review gate for healer pull requests
The guard is a shell script that reads the git diff of test files between two refs and flags the changes that matter: removed or changed expect( lines, added test.fixme and test.skip, added waitForTimeout, weaker matchers such as toBeTruthy and toContain, and added force: true. Exit code 1 means a person must look before the merge.
#!/usr/bin/env bash
# Review gate for a healer pull request.
# Usage: guard/check_healer_diff.sh <base-ref> [head-ref]
# Exit code 1 means a human must look before merge.
BASE="${1:-origin/main}"; HEAD="${2:-HEAD}"
DIFF=$(git diff "$BASE...$HEAD" -U0 -- 'tests/*.ts' 'tests/**/*.ts')
ADDED=$(printf '%s\n' "$DIFF" | grep -E '^\+' | grep -vE '^\+\+\+')
REMOVED=$(printf '%s\n' "$DIFF" | grep -E '^-' | grep -vE '^---')
fail=0
flag() { echo "REVIEW $1"; printf '%s\n' "$2" | sed 's/^/ /'; fail=1; }
R=$(printf '%s\n' "$REMOVED" | grep -E 'expect\(')
[ -n "$R" ] && flag "assertion removed or changed (the healer may have rewritten what correct means):" "$R"
S=$(printf '%s\n' "$ADDED" | grep -E 'test\.(fixme|skip)\(')
[ -n "$S" ] && flag "test skipped (check that it is not hiding a product defect):" "$S"
W=$(printf '%s\n' "$ADDED" | grep -E 'waitForTimeout\(')
[ -n "$W" ] && flag "fixed wait added (use a web-first assertion):" "$W"
M=$(printf '%s\n' "$ADDED" | grep -E '(toBeTruthy|toContain|toBeAttached|toBeDefined)\(')
[ -n "$M" ] && flag "possibly weaker matcher added:" "$M"
N=$(printf '%s\n' "$ADDED" | grep -E '\{ *force: *true')
[ -n "$N" ] && flag "force option added (it bypasses the checks a real user hits):" "$N"
CH=$(printf '%s\n' "$DIFF" | grep -cE '^[+-][^+-]')
[ "$fail" -eq 0 ] && echo "OK $CH changed lines, none touch assertions, skips, waits or matchers"
exit $fail
Patch
Guard result
A: locator only
OK. Two changed lines, none touch assertions, skips, waits or matchers
B: expected total changed
REVIEW. Assertion removed or changed, with the old 720.00 line shown
C: test.fixme added
REVIEW. Test skipped, with the added line shown
Playwright 1.65 lets test.skip(), test.fixme(), test.fail() and test.slow() take just a description. The guard's pattern still matches those forms, because it looks for the call, not its arguments.
The guard does not judge whether a change is right. It makes the risky categories impossible to miss and lets clean patches through quickly. In CI, run it on every pull request that touches tests/ and make a failing exit code a required review.
Rules for working with the healer
Never let a healer merge its own change. A person reads every diff that touches an assertion, a skip or a wait.
Treat a changed expected value as a product question. Someone who knows the requirement confirms the new value.
Treattest.fixmeas a bug report. Every skipped test needs a ticket and an owner, or the suite shrinks quietly.
Write the rule inAGENTS.md: never change an expected value to make a failing test pass, report the mismatch instead.
Keep the failing run. Attach the original failure to the pull request so the reviewer sees what the healer saw.
What is the difference between Playwright MCP vs test agents, CLI and codegen?
Tool
What it does
Who decides the steps
Best for
Codegen
Records your actions as code
You, by performing them
Quick first drafts
Playwright CLI
Command-line browser control for coding agents
The coding agent
Agents like Claude Code and Copilot working in a repo
Playwright MCP
Lets an AI agent drive a browser through MCP tools
The agent
LLM-driven exploration and automation
Test agents
Planner, generator and healer definitions with a test-running MCP server
The agents, guided by a plan
Structured plan, generate and repair loops
UI mode and trace viewer
Debugging and inspection
You
Understanding failures
If your team also uses AI to write code, the review habits in the guide to testing AI-generated code apply to generated tests too, and skills can package the review steps, as in agent skills for QA testing. The agents sit on the same machinery as the others. Their contribution is structure: a plan as an intermediate artifact, generation that is checked live and a repair loop. Their risk is that structure can look like process. A plan nobody reads and a healer nobody reviews are decoration. The guide to MCP for test automation explains the protocol underneath.
Should you use Playwright test agents?
Your situation
Recommendation
Playwright on Node.js, locator churn, new features needing a first draft
Good fit. Start with the planner on one small feature
Large suite that breaks after each release
Try the healer on failing tests only, behind the guard
Suite in Python, Java or .NET
Poor fit. The agents generate Node.js tests
Flows needing deep business judgement for expected results
Use agents for drafts, and write expected results yourself
No one will review diffs
Do not adopt. The review is the safety
A setup walkthrough for an existing project
Upgrade first. Move to the current Playwright release on a branch and run the suite unchanged. Node.js 20 is no longer tested in 1.65, so use 22, 24 or 26.
Runinit-agentsfor your assistant and commit the generated files as their own change.
Read the three definitions, noting what they permit, especially the healer's instruction to fix assertions.
Write standing rules where they survive regeneration:AGENTS.md, CLAUDE.md and lint.
Edit the seed test so it performs login and fixtures.
Run the planner on one small feature and review the plan before generating.
Add the guard to CI before the healer touches a real suite.
Review the first ten agent changes in detail, then decide where approvals can be lighter.
What goes wrong, and what to do about it
What goes wrong
Typical cause
What to do
The planner's scenarios miss your business rules
It learned the app from the page, not from requirements
Give it the requirement or a PRD and review expected results
Generated tests pass but check little
Weak assertions, such as visibility only
Lint for web-first assertions and require a meaningful assertion per test
The healer retries the same fix
A real product change or defect, not a locator problem
Cap attempts, then stop and ask a person
Tests tie to generated names
Selectors copied from the live page
Prefer roles, labels and test IDs, and add data-testid in the product
Edits to agent files disappear
init-agents regenerated them
Keep rules outside the agent files and review the diff after each update
The suite shrinks over time
Tests marked test.fixme and never fixed
Track skips with owners and fail CI over a skip budget
Results differ between machines
Version drift
Pin Playwright and assistant versions and record them in the pull request
The shrinking suite is the slow version of Patch C: no single skip looks serious, and the total quietly grows. A skip budget in CI makes the trend visible.
Putting the guard in CI
Run it on pull requests that change files under tests/, treat exit code 1 as a required manual review and attach its output to the pull request, so a reviewer sees flagged lines first. For a healer-generated pull request, also attach the original failing run. Over time, extend the script with patterns your reviewers care about, and tie each addition to a real pull request that needed it.
If you upgrade Playwright first, read the November 2026 roundup: 1.65 changes inert-element waits, aria snapshots, cookies and more, and those changes can fail tests before any agent touches them.
Frequently Asked Questions
What are Playwright test agents?
They are three agent definitions, a planner, a generator and a healer, that Playwright installs with npx playwright init-agents. The planner writes a Markdown test plan, the generator writes Playwright tests from it and the healer repairs failing tests. They run inside an assistant such as Claude Code or GitHub Copilot.
How do I set up Playwright test agents?
Run npx playwright init-agents --loop=claude for Claude Code or --loop=vscode for GitHub Copilot in VS Code. Other values are codex, copilot, opencode and vscode-legacy. The command writes agent definitions, an MCP configuration, a seed test and a specs folder. VS Code needs 1.105 or later.
What is the difference between the planner, generator and healer?
The planner explores the app and writes a plan, the generator turns the plan into test files and checks locators on the live page, and the healer fixes failing tests by replaying them and editing the code. The plan and the pull request are the review points.
Can the Playwright healer hide bugs?
Yes. A healer aims at a passing test, so it can change an expected value or mark a test test.fixme and reach green while a defect remains. In our experiment one patch changed an expected total from 720.00 to 792.00 and the suite passed with the bug in place. A diff guard and human review catch it.
Do Playwright test agents work with Python?
No. They generate Playwright Test code for Node.js in TypeScript or JavaScript, so a Python pytest suite is outside their scope. Teams on Python can still use the planner's idea, a reviewed plan before code, with their own tools.
What is a seed test in Playwright agents?
The seed test is a starter test that the planner runs to perform setup such as login, fixtures and hooks. The planner and generator both use it as the reference for setup and test structure, so a weak seed produces weak tests.
Should I commit the agent files?
Yes, so that regeneration after a Playwright update shows as a diff. Do not store your own rules in them, because re-running init-agents overwrites the definition files. Keep standing rules in AGENTS.md, CLAUDE.md and lint configuration.
Are Playwright test agents the same as Playwright MCP?
They are related but separate. The agents use a playwright-test MCP server that init-agents registers to drive the browser and run tests. Playwright MCP is the broader server that lets any compatible agent control a browser.
Conclusion
Playwright test agents, and self-healing Playwright tests in general, move the first draft of a test and some maintenance to an assistant. They do not move accountability. The planner needs a person to confirm expected results, the generator needs ordinary code review and the healer needs a gate, because the cheapest way to a green suite is to stop asking the product to be right. The three-patch experiment shows how small that difference looks in a test report and how clearly a short guard script can expose it.
Key Takeaways
Playwright test agents are a planner, a generator and a healer, installed with npx playwright init-agents --loop=<assistant>. They target Node.js Playwright Test, not pytest.
On 1.65.1 the loop choices are claude, codex, copilot, opencode, vscode and vscode-legacy. The command writes agent definitions, an MCP file, a seed test and a specs folder.
The seed test is the file that matters most: both the planner and generator use it for setup and structure.
Re-running init-agents overwrites the agent definition files. Keep standing rules in AGENTS.md, CLAUDE.md and lint, and commit the agent files so updates show as diffs.
Review the plan before the code. Expected results are business facts that need a person.
The healer aims at a passing run. A locator-only patch exposed a real defect (expected 720.00, received 792.00), a changed expectation hid it and a test.fixme parked it.
A guard that flags changed expect( lines, test.fixme, test.skip, fixed waits, weaker matchers and force: true passed the clean patch and flagged both risky ones.
Never let a healer merge its own change. Treat a changed expected value as a product question and every skip as a bug report.
This post ran the CLI, the app and the guard for real. The three healer patches were hand-written, and no language model was run.
Happy Testing!
PlaywrightPlaywright Test AgentsAI Test AutomationSelf-HealingMCPTest Maintenance
Hely PatelHead of Product and Marketing @AIdriventesting.ai. Leads the platform's AI testing tools from idea to launch, and writes about AI-driven testing and practical AI adoption for QA teams.