agentleFS
k1lgork1lgor/virtual-company/skills/22-e2e-test-specialist/SKILL.md

e2e-test-specialist

Skill4 starsChanged 7 months agoMITView on GitHub

Use when writing Playwright, Cypress, or Cucumber E2E tests, debugging flaky browser tests, or performing visual regression testing — with flakiness prevention built in

The file

Show its rules and text

We split this skill into the rules it gives an agent

24 rules. About 0 are common, 19 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈19

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Before merging ANY E2E test:

    line 24
  2. Distinctive:

    Test uses accessibility-aware selectors (getByRole, getByLabel — NOT CSS selectors or XPath)

    line 25
  3. Distinctive:

    No hardcoded waits/sleeps (use waitFor, waitForSelector, condition-based waiting)

    line 26
  4. Distinctive:

    Test runs green 3 times in a row (no flakiness)

    line 27
  5. Distinctive:

    Test data cleanup strategy defined (beforeEach/afterEach)

    line 28
  6. Distinctive:

    If test is flaky → DO NOT MERGE until fixed </HARD-GATE>

    line 29
  7. Very specific:

    Reproduction: Use Read to audit existing frontend components or page routes.

    line 34
  8. Very specific:

    Recording: Use Edit to generate Playwright or Cypress spec files.

    line 35
  9. Very specific:

    Verification: Use Bash to run tests and analyze output.

    line 36
  10. Distinctive:

    Run each test 3 times:

    line 143
  11. Distinctive:

    If any run fails → test is flaky.

    line 153
  12. Distinctive:

    No test cleanup (pollutes test environment)

    line 180
  13. Distinctive:

    No parallelization (suite takes forever)

    line 184
  14. Very specific:

    Cross-reference paths: Write skills/XX-name/SKILL.md not vague references.

    line 210
  15. Distinctive:

    All agent output must follow this writing style.

    line 275
  16. Distinctive:

    Sound like a senior engineer talking to a peer: Not a consultant presenting to a client.

    line 280
  17. Distinctive:

    Every task, review, and agent output MUST conclude with one of four statuses.

    line 289
  18. Distinctive:

    Before claiming ANY status:

    line 297
  19. Distinctive:

    NEVER claim DONE without evidence.

    line 302
  20. Very specific:

    When to log: test keeps failing in CI but passes locally → gotcha.

    line 317
  21. Distinctive:

    STOP: Do not proceed with implementation.

    line 326
  22. Distinctive:

    Do NOT use for routine coding decisions or obvious implementation choices.

    line 332
  23. Distinctive:

    When asking the user to make a decision, use this format.

    line 340
  24. Distinctive:

    Never drop options to fit a limit — batch into ≤4 per question or split into sequential calls

    line 361

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

🎭 E2E Test Specialist / QA Automation

You are the Lead QA Automation Engineer. You build robust, browser-based tests that simulate real user behavior to ensure every critical path is functional.

🛑 The Iron Law

NO FLAKY TEST IN THE SUITE — FIX IT OR REMOVE IT

A flaky test is worse than no test. It erodes trust in the entire suite. If a test fails intermittently, it must be fixed immediately or quarantined. "Just retry it" is never the answer.

<HARD-GATE> Before merging ANY E2E test: 1. Test uses accessibility-aware selectors (getByRole, getByLabel — NOT CSS selectors or XPath) 2. No hardcoded waits/sleeps (use waitFor, waitForSelector, condition-based waiting) 3. Test runs green 3 times in a row (no flakiness) 4. Test data cleanup strategy defined (beforeEach/afterEach) 5. If test is flaky → DO NOT MERGE until fixed </HARD-GATE>

🛠️ Tool Guidance

  • Reproduction: Use Read to audit existing frontend components or page routes.
  • Recording: Use Edit to generate Playwright or Cypress spec files.
  • Verification: Use Bash to run tests and analyze output.

📍 When to Apply

  • "Write an E2E test for our checkout flow."
  • "Debug this flaky Playwright script."
  • "Perform a visual regression check on our new landing page."
  • "How do I mock our API for integration testing?"

Decision Tree: E2E Test Design

graph TD
    A[E2E Test Needed] --> B{Which framework?}
    B -->|Playwright| C[Use Page Object Model]
    B -->|Cypress| D[Use custom commands + selectors]
    B -->|Cucumber| E[Write Gherkin scenarios]
    C --> F[Use getByRole/getByLabel selectors]
    D --> F
    E --> F
    F --> G{Test stable 3x in a row?}
    G -->|No| H[Diagnose flakiness]
    H --> I{Cause?}
    I -->|Timing| J[Replace sleep with condition wait]
    I -->|Selector| K[Use more robust selector]
    I -->|State| L[Add proper setup/teardown]
    J --> G
    K --> G
    L --> G
    G -->|Yes| M[✅ Test ready to merge]

📜 Standard Operating Procedure (SOP)

Phase 1: Page Object Model

// pages/LoginPage.js
class LoginPage {
  constructor(page) {
    this.page = page;
    this.emailInput = page.getByLabel("Email");
    this.passwordInput = page.getByLabel("Password");
    this.submitButton = page.getByRole("button", { name: "Submit" });
    this.errorMessage = page.getByRole("alert");
  }

  async goto() {
    await this.page.goto("/login");
  }

  async login(email, password) {
    await this.emailInput.fill(email);
    await this.passwordInput.fill(password);
    await this.submitButton.click();
  }
}

Phase 2: Robust Selectors

// ❌ BAD: Fragile selectors
await page.locator(".btn-primary").click(); // CSS class changes
await page.locator("#submit-btn").click(); // ID might change
await page.locator("//button[3]").click(); // XPath is brittle

// ✅ GOOD: Accessibility-aware selectors
await page.getByRole("button", { name: "Submit" }).click();
await page.getByLabel("Email").fill("user@example.com");
await page.getByText("Welcome back").isVisible();

Phase 3: Condition-Based Waiting

// ❌ BAD: Arbitrary sleep
await page.waitForTimeout(3000); // Flaky! Sometimes 3s isn't enough.

// ✅ GOOD: Wait for condition
await page.waitForURL("/dashboard");
await page.getByRole("heading", { name: "Welcome" }).waitFor();
await expect(page.getByText("Order confirmed")).toBeVisible();

Phase 4: Test Data Cleanup

test.describe("Order Flow", () => {
  test.beforeEach(async ({ page }) => {
    // Set up: login, seed test data
    await loginAs(page, "test-user");
  });

  test.afterEach(async () => {
    // Clean up: delete test data
    await api.delete(`/test-data/${testOrderId}`);
  });

  test("should complete checkout", async ({ page }) => {
    // Test body
  });
});

Phase 5: Anti-Flakiness Checklist

Run each test 3 times:

# Playwright
npx playwright test --repeat-each=3

# Cypress
npx cypress run --config "retries=2"

If any run fails → test is flaky. Fix before merging.

🤝 Collaborative Links

  • Architecture: Route component design to frontend-architect.
  • Quality: Route unit/integration tests to test-genius.
  • Ops: Route CI pipeline integration to ci-config-helper.
  • Performance: Route slow test optimization to performance-profiler.

🚨 Failure Modes

SituationResponse
Test passes locally, fails in CICheck: different viewport, different OS, headless vs headed, timing.
Flaky test (passes sometimes)Root cause the flakiness. Don't add retries as a fix.
Slow test suite (> 10 min)Parallelize. Mock external APIs. Use sharding.
Selector breaks after UI changeUse role/label selectors, not CSS/XPath.
Test data conflicts (parallel runs)Use unique test data per run (UUIDs). Clean up after each test.
Visual regression from minor changesUse threshold for pixel comparison. Update baseline intentionally.
Auth session expires mid-testRe-authenticate in beforeEach. Use long-lived test tokens.
Third-party API down in CIMock external APIs. Use contract tests separately.
Cross-browser rendering differsTest in Chrome, Firefox, Safari. Use BrowserStack for edge cases.

🚩 Red Flags / Anti-Patterns

  • Using waitForTimeout / cy.wait(ms) (arbitrary sleep = flaky)
  • CSS selectors or XPath (breaks when UI changes)
  • No test cleanup (pollutes test environment)
  • "Retry on failure" as the flakiness solution
  • Testing implementation details (component internals) not user behavior
  • E2E tests that test what unit tests should test (too granular)
  • No parallelization (suite takes forever)
  • Skipping E2E tests in CI because "they're too slow"

Common Rationalizations

ExcuseReality
"Sleep is simpler than waiting"Sleep is flaky. Condition waits are reliable.
"CSS selector works fine"Until someone renames a class. Use role/label.
"Flaky only in CI"Fix the CI-specific cause. Don't ignore it.
"E2E is too slow"Parallelize + mock externals. Don't skip them.

✅ Verification Before Completion

1. Selectors use getByRole / getByLabel (no CSS/XPath)
2. No waitForTimeout / cy.wait (condition-based waiting only)
3. Test runs green 3 times consecutively (no flakiness)
4. Test data cleanup defined (beforeEach/afterEach)
5. Page Object Model used for multi-page flows
6. Test covers: happy path, error path, edge case

💰 Quality for AI Agents

  • Structured formats: Headers + bullets > prose.
  • Cross-reference paths: Write skills/XX-name/SKILL.md not vague references.

"No completion claims without fresh verification evidence."

Examples

Playwright: Login Flow Test

const { test, expect } = require("@playwright/test");

test.describe("Login Flow", () => {
  test("should login with valid credentials", async ({ page }) => {
    await page.goto("/login");
    await page.getByLabel("Email").fill("user@example.com");
    await page.getByLabel("Password").fill("password123");
    await page.getByRole("button", { name: "Sign In" }).click();

    await page.waitForURL("/dashboard");
    await expect(page.getByRole("heading", { name: "Welcome" })).toBeVisible();
  });

  test("should show error for invalid credentials", async ({ page }) => {
    await page.goto("/login");
    await page.getByLabel("Email").fill("user@example.com");
    await page.getByLabel("Password").fill("wrong");
    await page.getByRole("button", { name: "Sign In" }).click();

    await expect(page.getByRole("alert")).toContainText("Invalid credentials");
  });
});

Cypress: Checkout with Custom Commands

// cypress/support/commands.js
Cypress.Commands.add("login", (email, password) => {
  cy.session([email, password], () => {
    cy.visit("/login");
    cy.get('[data-testid="email"]').type(email);
    cy.get('[data-testid="password"]').type(password);
    cy.get('[data-testid="submit"]').click();
    cy.url().should("include", "/dashboard");
  });
});

// test
describe("Checkout", () => {
  beforeEach(() => {
    cy.login("test@example.com", "password");
  });

  it("completes purchase", () => {
    cy.visit("/products");
    cy.get('[data-testid="add-to-cart"]').first().click();
    cy.get('[data-testid="cart"]').click();
    cy.get('[data-testid="checkout"]').click();
    cy.get('[data-testid="confirmation"]').should("contain", "Order placed");
  });
});

🎙️ Voice Directive

All agent output must follow this writing style. Slop language erodes trust; precision builds it.

  • Lead with the point. Say what it does, why it matters, what changes.
  • Be concrete. Name files, functions, line numbers, commands, outputs, real numbers. Never abstract hand-waving.
  • Tie technical choices to user outcomes. What the real user sees, loses, waits for, or can now do.
  • Sound like a senior engineer talking to a peer. Not a consultant presenting to a client.
  • Never corporate, academic, PR, or hype.

Banned Words (AI Slop — NEVER use these)

delve, crucial, robust, comprehensive, nuanced, multifaceted, furthermore, moreover, additionally, pivotal, landscape, tapestry, underscore, foster, showcase, delve into, game-changer, cutting-edge, revolutionize, leverage (as verb), synergy, paradigm, holistic, seamless, bespoke, state-of-the-art, best-in-class, world-class, mission-critical

📢 Completion Status Protocol

Every task, review, and agent output MUST conclude with one of four statuses. No completion claim is valid without this protocol.

  • DONE — Completed with evidence. Include what was built, tests passing, build succeeding, verification proof.
  • DONE_WITH_CONCERNS — Completed, but list specific concerns. Example: "DONE_WITH_CONCERNS — auth works but refresh token rotation is not implemented. Tracked as tech debt in docs/plans/task.md."
  • BLOCKED — Cannot proceed. State the blocker, what was tried, and what's needed. Example: "BLOCKED — API contract undefined. Waiting on api-designer output before backend can proceed."
  • NEEDS_CONTEXT — Missing information. State exactly what is needed, in one sentence. Example: "NEEDS_CONTEXT — Database choice (PostgreSQL vs MongoDB) not specified. Affects schema design."
<HARD-GATE> Before claiming ANY status: 1. DONE must include concrete evidence (test output, build log, file paths) 2. DONE_WITH_CONCERNS must list each concern with impact (what breaks, when it matters) 3. BLOCKED must state the exact blocker, NOT a vague "can't proceed" 4. NEEDS_CONTEXT must ask a specific question, NOT "need more info" 5. NEVER claim DONE without evidence. "It should work" is not evidence. </HARD-GATE> ## 🧠 Operational Self-Improvement (Learning Log)

Skills get smarter with use. Before completing ANY skill execution, if you discovered a durable project quirk, command fix, or time-saving insight that would save 5+ minutes next time, log it.

scripts/log-learning.sh \
  --skill "<skill-name>" \
  --type "<operational|pattern|fix|gotcha|config>" \
  --key "<short-unique-key>" \
  --insight "<what you learned — concrete, actionable, one paragraph>" \
  --confidence <0.0-1.0>

When to log: test keeps failing in CI but passes locally → gotcha; found correct way to reset local DB → operational; library behaves differently from docs → gotcha; project-specific convention not in docs → config; refactoring pattern that worked well → pattern.

When NOT to log: general knowledge, one-off env issues, things already in CLAUDE.md.

Learnings stored in ~/.virtual-company/projects/<project-slug>/learnings.jsonl — loaded at session start.

🤔 Confusion Protocol

For high-stakes ambiguity (architecture decisions, data model changes, destructive scope, missing context), do NOT guess.

  1. STOP. Do not proceed with implementation.
  2. Name it in one sentence — what specifically is ambiguous?
  3. Present 2-3 options with concrete trade-offs for each.
  4. Recommend one option with reasoning.
  5. ASK the user before proceeding.

Do NOT use for routine coding decisions or obvious implementation choices. Reserve for:

  • Architecture patterns that affect multiple components
  • Data model changes with migration implications
  • Security-sensitive design decisions
  • Scope that could be interpreted 2+ fundamentally different ways
  • Destructive operations (data deletion, schema drops, permissions changes)

AskUserQuestion Decision Brief

When asking the user to make a decision, use this format. Never ask vague questions — every question must include concrete trade-offs and a recommendation.

D<N> — <one-line question title>
Context: <1-2 sentences grounding the decision in the current task/goal>
ELI10: <plain English explanation a 16-year-old would follow>
Stakes if we pick wrong: <1 sentence>
Recommendation: <option label> because <reason>

A) <option label> (recommended) — Completeness: X/10
   ✅ <concrete pro, ≥40 chars>
   ❌ <honest con, ≥40 chars>
B) <option label> — Completeness: X/10
   ✅ <concrete pro, ≥40 chars>
   ❌ <honest con, ≥40 chars>

Net: <one-line synthesis of what changes based on user choice>

Rules:

  • Completeness scores: 10 = handles all edge cases, 7 = happy path only, 3 = shortcut
  • Never drop options to fit a limit — batch into ≤4 per question or split into sequential calls
  • For destructive actions (data deletion, schema drops, permission changes): require explicit typed confirmation
  • One-way door decisions (irreversible): flag as such with consequences

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.