agentleFS
EricTechProEricTechPro/startup-claude-skills/skills/playwright-qa-cli/SKILL.md

playwright-qa-cli

Skill56 starsChanged 6 months agoMITView on GitHub

Automated QA testing using playwright-cli (CLI tool, NOT MCP tools). Provisions a test user, opens a headless browser, logs in, navigates to target pages, takes screenshots, and generates a REPORT.md. Two modes: VERIFY (reproduce a bug before fixing) and CHECK (confirm a fix works). Use this skill whenever the user says 'QA this', 'test this fix', 'verify this bug', 'smoke test', 'check if this works', 'reproduce this issue', 'run playwright QA', or 'playwright-qa-cli'. Also triggered from /fix-ticket at pre-fix and post-fix stages. Works for any page or user flow — not limited to specific features.

  • Installs packages

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 3 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Do NOT use any mcp__plugin_playwright_playwright__* tools.

    line 13
  2. Very specific:

    All project-specific settings are defined in CONFIG.md at the root of this skill directory.

    line 35
  3. Very specific:

    Password note: Avoid !, \, $ in test passwords — playwright-cli fill escapes shell-special characters.

    line 45
  4. Very specific:

    Read the snapshot output to find element refs (e.g., e93 for Email, e99 for Password, e104 for Sign In).

    line 99
  5. Very specific:

    After clicking login, wait for the page to settle before taking a snapshot.

    line 109
  6. Distinctive:

    If you'll navigate multiple pages, save auth state to skip re-login on session loss:

    line 132
  7. Very specific:

    Use eval to wait for a meaningful signal rather than a blind sleep:

    line 152
  8. Distinctive:

    If that's too complex for the situation, a simple 2-3s wait is acceptable — just document why:

    line 159
  9. Very specific:

    Golden rule: Always snapshot before interacting with a new page.

    line 209
  10. Very specific:

    If WE_STARTED_SERVER, kill port 3000: lsof -ti:3000 | xargs kill 2>/dev/null

    line 219
  11. Distinctive:

    If skip_cleanup=true, skip the SQL cleanup but still close the browser.

    line 221

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Playwright QA (CLI Variant)

Automated headless-browser QA using playwright-cli bash commands. Provisions a test user, logs in, navigates to target pages, screenshots each step, generates REPORT.md, cleans up.

CRITICAL: No MCP Tools

Do NOT use any mcp__plugin_playwright_playwright__* tools. Use ONLY playwright-cli bash commands via the Bash tool. If playwright-cli is not found, STOP and ask user to install — do NOT fall back to MCP tools.

PATH Setup — REQUIRED

Prefix EVERY playwright-cli bash command with:

export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli ...

Parameters

ParameterDefaultExampleDescription
baseprodlocalprod = CONFIG.md PROD_URL, local = http://localhost:3000
modecheckverifyverify = reproduce bug, check = confirm fix
urlauto-detect/dashboard/receiptsPage to test
change_descriptionfrom git diff"Fixed button overflow"What to verify
ticket_idnonePROJ-123Issue tracker ticket (folder naming)
skip_cleanupfalsetrueKeep test user alive

Configuration

All project-specific settings are defined in CONFIG.md at the root of this skill directory. Before first use, copy CONFIG.example.md to CONFIG.md and fill in your values.

SettingSource
Test EmailCONFIG.md → TEST_USER_EMAIL
Test PasswordCONFIG.md → TEST_USER_PASSWORD
Supabase Project IDCONFIG.md → SUPABASE_PROJECT_ID
Production URLCONFIG.md → PROD_URL
Viewport1440x900

Password note: Avoid !, \, $ in test passwords — playwright-cli fill escapes shell-special characters.

Execution Flow

Phase 1:   Setup (mkdir screenshots, detect route from git diff)
Phase 1.5: Dev server (local only — check port 3000, start if needed)
Phase 2:   Provision test user → read references/provision.md
Phase 3:   Login via CLI → use state-save for auth persistence
Phase 4:   Navigate & test target page
Phase 5:   Cleanup → read references/cleanup.md + playwright-cli close
Phase 6:   Generate REPORT.md → read references/report-templates.md

Phase 1: Setup

mkdir -p playwright-qa-screenshots/{test-name}-{mode}

{test-name} = kebab-case from ticket ID or change description. {mode} = -verify or -check.

Route detection (if no url param): run git diff --name-only HEAD, map files to routes.

Customize the route detection table in CONFIG.md. Example format:

File PatternRoute
app/dashboard/page-a/**, components/page-a/**/dashboard/page-a
app/dashboard/page-b/**, components/page-b/**/dashboard/page-b
app/dashboard/settings/**/dashboard/settings
Default/dashboard

Phase 1.5: Dev Server (Local Only)

Skip if base=prod. Check lsof -ti:3000. If no server, start npm run dev in background, poll until ready (max 30s). Set WE_STARTED_SERVER flag for cleanup.

Phase 2: Provision Test User

Read references/provision.md and follow it exactly. It contains the complete Admin API flow, reset SQL, business profile creation, credits setup, and email verification.

Phase 3: Login via Playwright CLI

Open browser and navigate

export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli open "{base_url}/sign-in"
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli resize 1440 900
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli screenshot --filename=playwright-qa-screenshots/{test-name}/01-sign-in-page.png
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli snapshot

Find element refs and fill login form

Read the snapshot output to find element refs (e.g., e93 for Email, e99 for Password, e104 for Sign In). Refs change between pages — always snapshot before interacting.

export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli fill {email-ref} "{TEST_USER_EMAIL}"
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli fill {password-ref} "{TEST_USER_PASSWORD}"
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli click {submit-ref}

Wait for navigation and verify

After clicking login, wait for the page to settle before taking a snapshot. Use eval to check readiness instead of a blind sleep:

export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli eval "() => new Promise(r => setTimeout(r, 3000))"
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli snapshot
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli screenshot --filename=playwright-qa-screenshots/{test-name}/02-after-login.png

Why 3s here: Auth redirects involve a server round-trip + client-side redirect chain. This is one of the few places a timed wait is appropriate because there's no single DOM element that reliably signals "auth complete + redirect finished."

Verify redirect target

Customize these redirect targets in CONFIG.md to match your app's auth flow:

URL ContainsMeaningAction
/dashboardLogin succeededContinue to Phase 4
/verify-emailMissing email verificationFix via provision.md, retry
/setup or /onboardingMissing profile/onboardingRe-run provision setup, retry
/sign-inLogin failedRecreate user via Admin API

Save auth state (optional but recommended)

If you'll navigate multiple pages, save auth state to skip re-login on session loss:

export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli state-save playwright-qa-screenshots/{test-name}/auth-state.json

Restore later with playwright-cli state-load if the session drops.

Phase 4: Navigate & Test

Read references/cli-patterns.md for detailed interaction patterns (waiting, forms, dialogs, file uploads, scrolling, error checking). The patterns below are a summary.

Navigate to target page

export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli goto "{base_url}{target_route}"

Wait for page to load

Use eval to wait for a meaningful signal rather than a blind sleep:

# Wait for network idle (no pending fetches for 500ms)
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli eval "() => new Promise(resolve => { let timer; const check = () => { timer = setTimeout(resolve, 500); }; const observer = new PerformanceObserver(() => { clearTimeout(timer); check(); }); observer.observe({entryTypes: ['resource']}); check(); })"

If that's too complex for the situation, a simple 2-3s wait is acceptable — just document why:

# Simple wait — acceptable when page has heavy async rendering
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli eval "() => new Promise(r => setTimeout(r, 2000))"

Snapshot + screenshot

export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli snapshot
export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli screenshot --filename=playwright-qa-screenshots/{test-name}/03-target-page.png

Mode-specific testing

verify mode: Reproduce bug steps from ticket using CLI commands. Screenshot each step. Check playwright-cli console error for JS errors. Verdict: "Bug confirmed" or "Not reproducible".

check mode: Inspect snapshot for error indicators. Verify expected UI elements are present. Run change-specific checks. Check console for errors.

Expected elements by route

Customize this table in CONFIG.md to match your application's routes and expected elements:

RouteExpected Elements
/dashboardMain dashboard content, navigation
/dashboard/page-aPage A content or empty state
/dashboard/page-bPage B content or empty state
/dashboard/settingsSettings form

Key interaction commands

ActionCommand
Click elementplaywright-cli click {ref}
Fill inputplaywright-cli fill {ref} "text"
Type text (keystroke)playwright-cli type "text"
Select dropdownplaywright-cli select {ref} "value"
Upload fileplaywright-cli upload "/absolute/path/to/file"
Check checkboxplaywright-cli check {ref}
Press keyplaywright-cli press Enter / press Tab / press Escape
Scroll downplaywright-cli mousewheel 0 500
Full-page screenshotplaywright-cli screenshot --full-page --filename=...
Check JS errorsplaywright-cli console error
Check networkplaywright-cli network
Accept dialogplaywright-cli dialog-accept
Dismiss dialogplaywright-cli dialog-dismiss
Evaluate JSplaywright-cli eval "() => document.title"

Golden rule: Always snapshot before interacting with a new page. Element refs are page-specific and change after navigation or significant DOM updates.

Phase 5: Cleanup

Read references/cleanup.md and execute the SQL via your Supabase SQL execution tool. Then:

export PATH="$HOME/.npm-global/bin:$PATH" && playwright-cli close

If WE_STARTED_SERVER, kill port 3000: lsof -ti:3000 | xargs kill 2>/dev/null

If skip_cleanup=true, skip the SQL cleanup but still close the browser.

Phase 6: Report

Read references/report-templates.md and generate REPORT.md in the screenshots folder using the Write tool.

Error Handling

ScenarioAction
playwright-cli not foundSTOP. Tell user: npm install -g playwright-cli. Do NOT use MCP.
Stale browser sessionplaywright-cli kill-all then retry open
Login redirect to verify-emailFix email verification (see provision.md)
Login redirect to setup/onboardingRe-run profile creation (provision.md)
Login redirect back to sign-inRecreate user via Admin API
Element ref not foundRe-run snapshot — refs may have changed after DOM update
Supabase MCP unavailableSkip provisioning, ask user to log in manually
Cleanup failsLog warning, continue
Page shows loading spinnerWait with eval, then re-snapshot

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.