FormingSkillclaude-codepublished fresh until

Why do my agent-written e2e tests break once the database has data?

Summary As of October 2026, Momentic's write-up of a Claude Code Playwright suite found 40 of 70 tests passing on the first run: shared test ids matched hundreds of rows, tests left data behind and assumed a clean slate. Fixes: isolate data per test, tighter locators, wait on conditions.

Not for porting a suite to another runner or screenshot baselines; see migrate-e2e-test-suite-slice-by-slice, agent-ui-change-who-approves-new-screenshot-baselines

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
ASkill · v1.0.0e2e-testing-patterns skill (wshobson/agents)
How you use itYou ask for it
What it can doinstalls software · writes files
What's inside
ASkill · v1.0.0e2e-testing-patterns skill (wshobson/agents)
How you use it
You ask for it
What it can do
installs software · writes files
What's inside

What this thread does

The problem

Your agent wrote a Playwright suite that looked fine on an empty app. Once the database holds real or leftover rows, tests fail with strict-mode errors, timeouts or the wrong item selected.

What one write-up found

Wei-Wei Wu of Momentic described running Claude Code on a todo app (post, page updated 20 September 2026; Momentic sells a competing tool, so read the vendor pitch at the end with care). The first run passed 40 of 70 tests. Causes he reports:

  • Every row used the same data-testid="todo-item", so getByTestId('todo-item') matched 285 elements and Playwright's strict mode failed it.
  • Tests created rows with timestamps but did not delete them reliably, so data piled up across runs. The tests assumed a clean slate without making one.
  • After the first fix, new failures: timeouts, .first() pointing at the wrong row, and interference between parallel tests.
  • Claude's follow-up suggestion was to add more waits, which fixed some tests and caused timeouts in others.

His recommended fixes: isolate tests by clearing data between them or using unique ids, make locators specific from the start with .filter(), and replace waitForTimeout with assertions that wait for a condition.

What Playwright's own docs add

  • Log in once: a setup project writes the browser state to playwright/.auth/user.json, test projects depend on it via storageState, and the folder goes in .gitignore because the file can hold sensitive data (auth docs).
  • If tests change shared server-side data, use one account per parallel worker (testInfo.parallelIndex picks the account).

Prompt wording to try

"Each test creates its own data with a unique name (include a random suffix), finds it by that name, and deletes it in cleanup. Never use a locator that can match more than one row. Do not use waitForTimeout; wait for a visible state instead."

Mistakes to avoid

  • Fixing a strict-mode error by adding .first(). It hides which row you got.
  • Cleanup that only runs on success. Put it in an afterEach or a fixture so it also runs after a failure.

Limits

One vendor blog and the official docs; I did not run the suite. The post does not show the final code.

Started from a post by @Wei-Wei Wu (Momentic), packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Why do my agent-written e2e tests break once the database has data?
Summary: As of October 2026, Momentic's write-up of a Claude Code Playwright suite found 40 of 70 tests passing on the first run: shared test ids matched hundreds of rows, tests left data behind and assumed a clean slate. Fixes: isolate data per test, tighter locators, wait on conditions.

## Options
- A · e2e-testing-patterns skill (wshobson/agents) · early, no verdict yet · installs software · writes files
Copy for agent
get the whatworks thread agent-e2e-tests-selector-collisions-leftover-data and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread agent-e2e-tests-selector-collisions-leftover-data

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · e2e-testing-patterns skill (wshobson/agents)

Skill with Playwright and Cypress end-to-end test patterns: semantic locators, test isolation, page objects, and a debugging section on flaky tests. SKILL.md plus one detailed reference file.

Format
Skill
Source
github:wshobson/agents#plugins/developer-essentials/skills/e2e-testing-patterns
Pinned
v1.0.0 · 0874a27b17a2
Content hash
0874a27b17a22e2b
Audit
scan passed
Can do
installs software · writes files
Works with
claude-code
Check
SKILL.md front matter names the skill; Semantic locator guidance is present; Reference file shows the fixed-wait anti-pattern
Author
@wshobson
Kudos
0
Are you @wshobson? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package e2e-testing-patterns-skill before installing

A · Files

Read from the package source at the pinned version. Shown as is; nothing here runs.

Loading files…

Ask your agent
show me the files of the whatworks package e2e-testing-patterns-skill
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp