agentleFS
cohen-lielcohen-liel/hivemind/.claude/skills/e2e-testing/SKILL.md

e2e-testing

Skill110 starsChanged 9 months agoApache-2.0View on GitHub

End-to-end testing patterns with Playwright. Use when writing browser automation tests, integration tests, testing user flows, or setting up E2E test suites.

  • Reads credentials

48 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use swift-protocol-di-testing, content-hash-cache-pattern and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • InfopibeSkill

    swift-protocol-di-testing

    Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.

    Also in 8 projects that use this

  • InfopibeSkill

    content-hash-cache-pattern

    Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

    Also in 8 projects that use this

  • saxon-ySkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 7 projects that use this

  • +8 more from Infopibe

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 23 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use Page Object Model — never write raw selectors in test bodies

    line 144
  2. Distinctive:

    Prefer role/label selectors over CSS selectors (more resilient)

    line 145
  3. Distinctive:

    Never use waitForTimeout() — use waitForResponse or waitForSelector

    line 148
  4. Distinctive:

    Run E2E against production build in CI

    line 149

“Common” is measured: kept by at least 6 in 10 of the 23 edited versions of this file we could read. “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

End-to-End Testing Patterns (Playwright)

Setup

npm init playwright@latest
npx playwright install  # Install browsers
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test'
export default defineConfig({
  testDir: './tests/e2e',
  fullyParallel: true,
  retries: process.env.CI ? 2 : 0,
  use: {
    baseURL: 'http://localhost:3000',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
  },
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
    { name: 'firefox', use: { ...devices['Desktop Firefox'] } },
    { name: 'Mobile Safari', use: { ...devices['iPhone 13'] } },
  ],
  webServer: {
    command: 'npm run dev',
    url: 'http://localhost:3000',
    reuseExistingServer: !process.env.CI,
  },
})

Page Object Model

// tests/e2e/pages/LoginPage.ts
import { Page, Locator } from '@playwright/test'
export class LoginPage {
  readonly emailInput: Locator
  readonly passwordInput: Locator
  readonly submitButton: Locator
  readonly errorMessage: Locator

  constructor(private page: Page) {
    this.emailInput = page.getByLabel('Email')
    this.passwordInput = page.getByLabel('Password')
    this.submitButton = page.getByRole('button', { name: 'Sign in' })
    this.errorMessage = page.getByRole('alert')
  }

  async goto() { await this.page.goto('/login') }
  async login(email: string, password: string) {
    await this.emailInput.fill(email)
    await this.passwordInput.fill(password)
    await this.submitButton.click()
  }
}

Writing Tests

import { test, expect } from '@playwright/test'
import { LoginPage } from './pages/LoginPage'

test.describe('Authentication', () => {
  test('login with valid credentials', async ({ page }) => {
    const loginPage = new LoginPage(page)
    await loginPage.goto()
    await loginPage.login('user@example.com', 'password123')
    await expect(page).toHaveURL('/dashboard')
  })

  test('show error for invalid credentials', async ({ page }) => {
    const loginPage = new LoginPage(page)
    await loginPage.goto()
    await loginPage.login('wrong@email.com', 'wrong')
    await expect(loginPage.errorMessage).toContainText('Invalid credentials')
  })
})

Reuse Auth State

// tests/e2e/auth.setup.ts
import { test as setup } from '@playwright/test'
setup('authenticate', async ({ page }) => {
  await page.goto('/login')
  await page.fill('[name=email]', 'test@example.com')
  await page.fill('[name=password]', 'password')
  await page.click('[type=submit]')
  await page.waitForURL('/dashboard')
  await page.context().storageState({ path: 'tests/e2e/.auth/user.json' })
})

// playwright.config.ts — add these projects:
// { name: 'setup', testMatch: '**/auth.setup.ts' },
// { name: 'authenticated', dependencies: ['setup'], use: { storageState: '...' } }

API Mocking

test('displays mocked products', async ({ page }) => {
  await page.route('**/api/products', async (route) => {
    await route.fulfill({
      status: 200,
      contentType: 'application/json',
      body: JSON.stringify([{ id: '1', name: 'Test Product', price: 99.99 }]),
    })
  })
  await page.goto('/products')
  await expect(page.getByText('Test Product')).toBeVisible()
})

Common Assertions

await expect(element).toBeVisible()
await expect(element).toContainText('partial text')
await expect(page).toHaveURL('/dashboard')
await expect(page.getByRole('listitem')).toHaveCount(5)
await expect(input).toHaveValue('hello')
await expect(button).toBeDisabled()

// Wait for network response
const response = await page.waitForResponse('**/api/submit')
expect(response.status()).toBe(200)

Running Tests

npx playwright test                  # All tests
npx playwright test auth.spec.ts     # Specific file
npx playwright test --headed         # Show browser
npx playwright test --ui             # Interactive UI
npx playwright show-report           # HTML report

Rules

  • Use Page Object Model — never write raw selectors in test bodies
  • Prefer role/label selectors over CSS selectors (more resilient)
  • Save auth state with storageState — don't login in every test
  • Mock external APIs (payment, email) — test in isolation
  • Never use waitForTimeout() — use waitForResponse or waitForSelector
  • Run E2E against production build in CI
  • E2E for critical paths only — unit test business logic separately

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.