← GUIDES

GUIDE / SETUP NOTE

Playwright Test Agents: Draft E2E Tests, Then Review

Set up Playwright's planner, generator and healer agents in Claude Code, point them at a test environment, and review every test, including fixme.

5 Nov 2026Checked 2026-10-28
Playwright planner, generator and healer agents turning a Markdown test plan into test files, with a person reviewing the result

Playwright by Microsoft, Apache-2.0, v1.64.1 (released 2026-10-14). Agent definitions generated locally with npx playwright init-agents --loop=claude on 2026-10-28.

Playwright's three test agents (planner, generator and healer) can draft end-to-end tests for your app from a plain request. Run them against a test environment, then review the plan, the test files and every test the healer changed or marked test.fixme() before you merge.

The agents do the typing. You decide whether the tests check the right things.

Based on Playwright, by Microsoft, Apache-2.0 licensed. We checked the Test Agents docs and v1.64.1, released 14 October 2026, and generated the Claude Code agent files ourselves with that version on 28 October 2026. Agent files change between releases, so regenerate and reread yours.

What the three agents do

From the docs:

  • Planner "explores the app and produces a Markdown test plan", saved under specs/.
  • Generator "transforms the Markdown plan into the Playwright Test files" under tests/, checking selectors and assertions live as it goes.
  • Healer "executes the test suite and automatically repairs failing tests".

You can use them one at a time or chain them. The docs note that generated tests "may include initial errors", which is what the healer is for.

Step 1: Generate the agent definitions

In a project that already uses Playwright Test, run the command for your tool:

bash
npx playwright init-agents --loop=claude

The docs also list --loop=vscode, --loop=codex and --loop=opencode. For VS Code, they say version 1.105 or later is needed.

With v1.64.1 and --loop=claude, our run created:

  • .claude/agents/playwright-test-planner.md, playwright-test-generator.md and playwright-test-healer.md
  • .mcp.json, which starts a playwright-test MCP server with npx playwright run-test-mcp-server
  • seed.spec.ts, an empty seed test
  • specs/README.md

The docs say these definitions "should be regenerated whenever Playwright is updated". Commit them so changes show up in review.

Step 2: Read what each agent is allowed to do

Each agent file lists its tools at the top. In our generated files:

  • The planner can read files and drive the browser: open pages, click, type, upload files, take screenshots. Its list also includes a tool named browser_run_code_unsafe.
  • The generator can drive the browser and write tests through the MCP server's generator_write_test tool.
  • The healer can run and debug tests, and it has Claude Code's Edit, MultiEdit and Write tools, so it edits files in your repo directly.

The healer's instructions also say: "Do not ask user questions, you are not interactive tool, do the most reasonable thing possible to pass the test." That's fine for a test drafter, as long as a person reviews the result.

Step 3: Point the agents at a test environment

The planner and generator click through your real UI. Give them somewhere safe to do it:

  • a local or staging build, not production
  • test accounts with no real customer data or payment methods
  • a seed test that logs in and sets up state the same way every time

The seed test matters. Per the docs, the planner runs it to do "all the initialization necessary for your test", including global setup and fixtures, and uses it as the example for every generated test.

Step 4: Plan, then read the plan

Ask the planner for one flow at a time, for example: "Generate a plan for guest checkout." You can add a product requirements document for context.

Read the Markdown plan in specs/ before generating anything. It lists steps and expected results in plain language, so it's the cheapest place to catch a wrong assumption. Edit it until the expected results match what your product should do.

Step 5: Generate, run, and heal

Give the generator the plan file. It writes tests under tests/, with comments that point back to the spec and seed. Run them yourself with npx playwright test.

When a test fails, the healer replays the failing steps, inspects the UI, suggests a patch such as a locator update or wait adjustment, and "re-runs the test until it passes or until guardrails stop the loop". Its output is "a passing test, or a skipped test if the healer believes that functionality is broken."

Step 6: Review before you merge

This is the human approval step, and it's where the real value is. Open the diff and check:

  1. Every test.fixme(). The generated healer instructions say that if an error persists and it's confident the test is correct, it marks the test test.fixme() so it's skipped, with a comment. A skipped test may be pointing at a real bug. Read the comment and decide.
  2. Weakened assertions. A test can pass because an expectation was loosened. Compare each healed test to its spec.
  3. Locators. Prefer role- and label-based locators like getByRole, which the docs' examples use.
  4. Scope. Generated tests should map to the plan; the docs say they align "one-to-one with specs wherever feasible".

Merge only what you'd have been happy to write yourself.

The takeaway

Playwright's planner, generator and healer draft end-to-end tests quickly. Run them against a test environment with test accounts, read the plan before generating, and review every healed or fixme test before merging.

Next step

For browser automation outside tests, see our Playwright MCP kit. Read how we verify kits, or find an agent for the job.

Good setups, worth keeping. Request email updates on the home page, then confirm by email. No subscription starts until you confirm.

Part of: Which setup should I use to add human approval to an agent?

Your privacy choices

Choose optional tools. Rejecting them keeps the setup library available. Advertising consent stays off.

Choices stay in this browser for 90 days. You can change them using Privacy settings. Privacy and cookie details