Playwright stability
Skill LFTPadilla/agent-dev-kit/plugins/dev-skills/skills/playwright-stability
Replicable agent development system: curated Claude Code/Codex skills + bootstrap for the external tools (GSD, caveman, ponytail) that complete the stack.
npx -y skills add LFTPadilla/agent-dev-kit --skill playwright-stabilityAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Make a Playwright E2E suite stable and realistic — kill flaky tests and authenticate like a real user via storageState (login once, reuse). Use when E2E tests are flaky, slow, re-login in every test, mock auth instead of using it, or when hardening a suite before relying on it.
SKILL.md
2.7 KB, as published. Nobody here has run it
Playwright stability & real-user auth
Two jobs: (1) stop flakes, (2) authenticate like a real user without paying the login cost per test. Both raise realism and reliability at once.
Anti-flaky checklist
- Locators by role first.
getByRole(name)→getByLabel→getByText→getByTestId. CSS/XPath last. Role locators double as an accessibility check. - Web-first assertions only.
await expect(locator).toBeVisible()auto-waits. NeverwaitForTimeout, never assert on a snapshot you grabbed manually. - No manual sleeps. Replace every fixed wait with an assertion on the state you actually need (
toHaveURL,toBeEnabled,toHaveText). - Trace on first retry + screenshot on failure. Open the Trace Viewer before editing flaky code — DOM/network/console at each step finds the cause in minutes.
retries: 2in CI, 0 locally (a local flake is a bug to fix, not retry).- Isolate. Each test sets up its own data; no shared mutable state, no order dependency.
- One clean server. Kill stray dev servers and confirm the port is free before a full run — a stale server serves old assets and fakes failures.
Real-user auth via storageState (stop mocking the session)
Mocking auth is the least realistic part of a suite. Instead log in once, save the browser state, and every test starts already authenticated — real tokens, real session, near-zero per-test cost.
See templates/playwright/auth.setup.ts
and the config snippet beside it.
- Run the provider's real login (WorkOS / Cognito / Auth0 / your own form) in a
setupproject, thencontext.storageState({ path }). - Other projects depend on that setup and load
storageState. - Keep the state file out of git (it holds live tokens) and regenerate it at the start of each CI run — never commit and reuse across days.
- MFA / bot-protected SSO: do the login interactively once, persist the state, refresh when it expires. Credentials come from env vars, never hardcoded.
Config (the bits that matter)
export default defineConfig({
retries: process.env.CI ? 2 : 0,
use: { trace: 'on-first-retry', screenshot: 'only-on-failure' },
projects: [
{ name: 'setup', testMatch: /auth\.setup\.ts/ },
{ name: 'chromium', dependencies: ['setup'],
use: { storageState: 'playwright/.auth/user.json' } },
],
})