e2e-testing
Skill13 starsChanged 8 months agoMITView on GitHub
Playwright E2E testing patterns including page object model, fixtures, parallel execution, flaky test prevention, visual regression, API mocking, and cross-browser testing.
- Reads credentials
48 other projects use a version of this, 23 of them edited.
Adopted by
Most recently taken up by
- Lukk17/agent-standardstheir own version, first seen Oct 5, 2026
- CrowdStrike/foundry-skillstheir own version, first seen Oct 1, 2026
- philtzjp/skillstheir own version, first seen Sep 30, 2026
- Cure-Consulting-Group/ProductEngineeringSkillstheir own version, first seen Sep 28, 2026
- mthines/agent-skillstheir own version, first seen Sep 25, 2026
- HACK-WU/skillstheir own version, first seen Sep 23, 2026
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.
InfopibeSkillswift-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
InfopibeSkillcontent-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-ySkillconfigure-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
Other versions48 projects use a version of this.
Word for word · 0
None found.
Edited · 23
- xu-xiang/everything-claude-code-zh★ 2k12% same
- loulanyue/awesome-claude-notes★ 27212% same
- tpavanipradeep/everything-claude-code★ 13412% same
- templetongroup/radiant★ 11312% same
- cohen-liel/hivemind★ 11027% same
- Jamkris/everything-gemini-code★ 8711% same
- woxiangyangzhimao/skills★ 1411% same
- Infopibe/everything-claude-code★ 812% same
- YepAPI/skills★ 811% same
- zero-click/zero-ratchet★ 812% same
13 more not listed
Wrote their own version · 25
- nodetool-ai/nodetool★ 551same name
- ai-dashboad/flutter-skill★ 384same name
- JasonxzWen/harness-hub★ 71same name
- nahid-sparktales/agent-dispatcher★ 59same name
- drvoss/everything-copilot-cli★ 47same name
- Svenja-dev/claude-code-skills★ 38same name
- CrowdStrike/foundry-skills★ 30same name
- mhylle/claude-skills-collection★ 19same name
- mthines/agent-skills★ 13same name
- pekral/cursor-rules★ 10same name
15 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository60 other files it gives its agents.
- AGENTS.mdAGENTS.md
- examples/CLAUDE.mdCLAUDE.md
- agentic-engineeringSkill
- api-designSkill
- api-integrationsSkill
- architecture-decision-recordsSkill
- autonomous-agent-harnessSkill
- autonomous-loopsSkill
- aws-deploymentSkill
- aws-devopsSkill
- backend-patternsSkill
- backlog-managementSkill
- ci-pipelineSkill
- claude-apiSkill
- codebase-onboardingSkill
- codebase-reportSkill
- code-reviewSkill
- coding-standardsSkill
- context-pruneSkill
- continuous-agent-loopSkill
- database-migrationsSkill
- data-pipelines-aiSkill
- data-pipelinesSkill
- deep-researchSkill
- deployment-patternsSkill
- dmux-workflowsSkill
- docker-patternsSkill
- documentation-lookupSkill
- document-processingSkill
- eval-harnessSkill
- exa-searchSkill
- frontend-designSkill
- frontend-patternsSkill
- github-opsSkill
- git-workflowSkill
- hexagonal-architectureSkill
- iterative-retrievalSkill
- langchain-llamaindexSkill
- mcp-server-patternsSkill
- mlops-ragSkill
- mlops-workflowSkill
- multi-agent-git-workflowSkill
- observability-telemetrySkill
- openai-apiSkill
- postgres-patternsSkill
- prompt-optimizerSkill
- python-patternsSkill
- python-testingSkill
- pytorch-patternsSkill
- search-firstSkill
- security-reviewSkill
- security-scanSkill
- skill-authoringSkill
- tdd-workflowSkill
- technical-debt-reportSkill
- token-budget-advisorSkill
- typescript-patternsSkill
- verification-loopSkill
- workflow-statusSkill
- wxt-chrome-extensionSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 23 edited versions we read keep these.
5
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
- Distinctive: line 26
Not every path needs an E2E test.
- Distinctive: line 147
Use Playwright fixtures to set up test state and avoid duplication:
- Distinctive: line 362
Update baselines after intentional UI changes:
- Distinctive: line 374
Run the same test suite across multiple browsers:
- Distinctive: line 400
Test date inputs with explicit format handling:
“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.
Files
E2E Testing with Playwright
Comprehensive E2E testing patterns using Playwright. Covers page object model, test fixtures, parallel execution, flaky test prevention, visual regression, API mocking, and cross-browser validation. Use this skill when writing or maintaining E2E tests for web applications.
When to Use
- Writing new E2E tests for critical user flows
- Converting manual QA scenarios to automated tests
- Debugging flaky E2E tests
- Setting up cross-browser test infrastructure
- Implementing visual regression testing
- Mocking external APIs in end-to-end scenarios
- Establishing E2E testing standards for a project
Core Concepts
Critical User Flows
Not every path needs an E2E test. Focus on flows that represent real user journeys:
| Priority | Flow | Example |
| P0 | Authentication | Sign up → verify email → log in |
| P0 | Core transaction | Add to cart → checkout → payment confirmation |
| P1 | CRUD operations | Create item → edit → delete → verify removal |
| P1 | Search and filter | Search → apply filter → verify results |
| P2 | Settings and profile | Update profile → save → verify persistence |
| P3 | Edge cases | Session timeout → redirect → re-auth |
P0 and P1 flows should be covered by E2E tests. P2 and P3 are optional based on project scope.
Page Object Model (POM)
Encapsulate page interactions in reusable, maintainable classes:
// tests/pages/LoginPage.ts
import { Page, Locator, expect } from '@playwright/test'
export class LoginPage {
readonly page: Page
readonly emailInput: Locator
readonly passwordInput: Locator
readonly submitButton: Locator
readonly errorMessage: Locator
constructor(page: Page) {
this.page = page
this.emailInput = page.getByLabel('Email')
this.passwordInput = page.getByLabel('Password')
this.submitButton = page.getByRole('button', { name: 'Sign In' })
this.errorMessage = page.getByTestId('login-error')
}
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()
}
async expectLoggedInUser(name: string) {
await expect(this.page.getByText(name)).toBeVisible()
}
async expectError(message: string) {
await expect(this.errorMessage).toContainText(message)
}
}// tests/pages/DashboardPage.ts
import { Page, Locator, expect } from '@playwright/test'
export class DashboardPage {
readonly page: Page
readonly welcomeHeading: Locator
readonly createItemButton: Locator
readonly itemList: Locator
constructor(page: Page) {
this.page = page
this.welcomeHeading = page.getByRole('heading', { name: /welcome/i })
this.createItemButton = page.getByRole('button', { name: 'Create Item' })
this.itemList = page.getByTestId('item-list')
}
async goto() {
await this.page.goto('/dashboard')
}
async createItem(name: string) {
await this.createItemButton.click()
await this.page.getByLabel('Item Name').fill(name)
await this.page.getByRole('button', { name: 'Save' }).click()
}
async expectItemExists(name: string) {
await expect(this.itemList.getByText(name)).toBeVisible()
}
}// tests/e2e/auth-flow.spec.ts
import { test, expect } from '@playwright/test'
import { LoginPage } from '../pages/LoginPage'
import { DashboardPage } from '../pages/DashboardPage'
test.describe('Authentication Flow', () => {
test('user can log in and access dashboard', async ({ page }) => {
const loginPage = new LoginPage(page)
const dashboardPage = new DashboardPage(page)
await loginPage.goto()
await loginPage.login('alice@example.com', 'correct-password')
await dashboardPage.expectLoggedInUser('Alice')
await expect(page).toHaveURL(/\/dashboard/)
})
test('invalid credentials show error message', async ({ page }) => {
const loginPage = new LoginPage(page)
await loginPage.goto()
await loginPage.login('alice@example.com', 'wrong-password')
await loginPage.expectError('Invalid email or password')
await expect(page).toHaveURL(/\/login/)
})
})Test Fixtures
Use Playwright fixtures to set up test state and avoid duplication:
// tests/fixtures/auth.ts
import { test as base, Page } from '@playwright/test'
import { LoginPage } from '../pages/LoginPage'
type AuthFixtures = {
loginPage: LoginPage
authenticatedPage: Page
}
export const test = base.extend<AuthFixtures>({
loginPage: async ({ page }, use) => {
const loginPage = new LoginPage(page)
await use(loginPage)
},
authenticatedPage: async ({ page }, use) => {
// Auto-login before each test
await page.goto('/login')
await page.getByLabel('Email').fill('testuser@example.com')
await page.getByLabel('Password').fill('testpass123')
await page.getByRole('button', { name: 'Sign In' }).click()
await page.waitForURL(/\/dashboard/)
await use(page)
},
})
export { expect } from '@playwright/test'// tests/e2e/item-management.spec.ts
import { test, expect } from '../fixtures/auth'
test.describe('Item Management', () => {
test('create and verify item', async ({ authenticatedPage }) => {
await authenticatedPage.goto('/dashboard')
await authenticatedPage.getByRole('button', { name: 'Create Item' }).click()
await authenticatedPage.getByLabel('Item Name').fill('Test Widget')
await authenticatedPage.getByRole('button', { name: 'Save' }).click()
await expect(authenticatedPage.getByTestId('item-list').getByText('Test Widget')).toBeVisible()
})
})Flaky Test Prevention
Root Causes and Solutions
| Cause | Symptom | Fix |
| Timing issues | Element not found intermittently | Use waitFor assertions, not sleep() |
| Shared state | Tests pass/fail depending on order | Isolate data per test, clean up after |
| Network variability | API timeouts, slow responses | Mock external APIs, set generous timeouts |
| Animation/transitions | Element visible but not clickable | Wait for animation to complete or disable in test mode |
| Dynamic content | IDs/text change between runs | Use stable selectors (data-testid, roles) |
Anti-Pattern vs. Correct Pattern
// BAD: Fixed sleep — timing dependent
await page.click('button')
await page.waitForTimeout(2000) // Flaky on slow CI
await expect(page.getByText('Success')).toBeVisible()
// GOOD: Wait for the actual state change
await page.click('button')
await expect(page.getByText('Success')).toBeVisible({ timeout: 10000 })// BAD: Brittle CSS selector
await page.click('.css-1a2b3c')
// GOOD: Semantic selector with data-testid
await page.click('[data-testid="submit-button"]')
// GOOD: Role-based selector (preferred)
await page.click('role=button[name="Submit"]')Retry and Trace Configuration
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test'
export default defineConfig({
testDir: './tests/e2e',
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 4 : undefined,
timeout: 30_000,
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
{
name: 'mobile-chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'mobile-safari',
use: { ...devices['iPhone 12'] },
},
],
webServer: {
command: 'npm run dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
})API Mocking
Mock external APIs to ensure deterministic, fast E2E tests:
// tests/e2e/payment-flow.spec.ts
import { test, expect } from '@playwright/test'
test.describe('Payment Flow', () => {
test('successful payment completes order', async ({ page }) => {
// Mock Stripe API
await page.route('**/api/stripe/create-payment-intent', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
clientSecret: 'pi_test_secret_123',
id: 'pi_123',
}),
})
})
// Mock order confirmation webhook
await page.route('**/api/webhooks/stripe', async (route) => {
await route.fulfill({
status: 200,
body: JSON.stringify({ received: true }),
})
})
await page.goto('/checkout')
await page.fill('[data-testid="card-number"]', '4242424242424242')
await page.fill('[data-testid="card-expiry"]', '12/30')
await page.fill('[data-testid="card-cvc"]', '123')
await page.click('[data-testid="pay-button"]')
await expect(page.getByText('Payment Successful')).toBeVisible()
await expect(page).toHaveURL(/\/order-confirmation/)
})
test('failed payment shows error', async ({ page }) => {
await page.route('**/api/stripe/create-payment-intent', async (route) => {
await route.fulfill({
status: 402,
body: JSON.stringify({ error: { message: 'Card declined' } }),
})
})
await page.goto('/checkout')
await page.click('[data-testid="pay-button"]')
await expect(page.getByText('Card declined')).toBeVisible()
})
})Visual Regression Testing
Capture and compare screenshots to detect unintended UI changes:
// tests/e2e/visual-regression.spec.ts
import { test, expect } from '@playwright/test'
test.describe('Visual Regression', () => {
test('login page matches baseline', async ({ page }) => {
await page.goto('/login')
await expect(page).toHaveScreenshot('login-page.png', {
maxDiffPixels: 100,
fullPage: true,
})
})
test('dashboard layout is stable', async ({ page }) => {
await page.goto('/dashboard')
// Wait for all async content to load
await page.waitForSelector('[data-testid="item-list"]')
await expect(page).toHaveScreenshot('dashboard-layout.png', {
maxDiffPixels: 200,
})
})
test('mobile login page matches baseline', async ({ page }) => {
await page.setViewportSize({ width: 375, height: 667 })
await page.goto('/login')
await expect(page).toHaveScreenshot('login-mobile.png', {
maxDiffPixels: 100,
fullPage: true,
})
})
})Update baselines after intentional UI changes:
# Update visual baselines
npx playwright test --update-snapshots
# Run visual tests only
npx playwright test visual-regression --project=chromiumCross-Browser Testing
Run the same test suite across multiple browsers:
# Install all browsers
npx playwright install
# Run all browser projects
npx playwright test --project=chromium --project=firefox --project=webkit
# Run only mobile browsers
npx playwright test --project=mobile-chrome --project=mobile-safari
# Run with HTML report
npx playwright test --reporter=html
npx playwright show-reportBrowser-Specific Quirks to Watch For
| Issue | Chromium | Firefox | WebKit |
| Date input format | yyyy-MM-dd | MM/dd/yyyy | dd/MM/yyyy |
| File upload behavior | Native dialog | Native dialog | May need setInputFiles |
| CSS support | Full | Full | Minor gaps in older versions |
| Cookie handling | Third-party blocked by default | User-configurable | ITP restrictions |
Test date inputs with explicit format handling:
// Handle date inputs across browsers
async function fillDateInput(page, selector: string, date: Date) {
const formatted = date.toISOString().split('T')[0] // yyyy-MM-dd
await page.fill(selector, formatted)
// Verify the browser accepted the value
const actual = await page.inputValue(selector)
expect(actual).toBe(formatted)
}E2E Test Organization
project/
├── tests/
│ ├── e2e/
│ │ ├── auth-flow.spec.ts # Login, signup, password reset
│ │ ├── item-management.spec.ts # CRUD operations
│ │ ├── payment-flow.spec.ts # Checkout, Stripe mock
│ │ └── visual-regression.spec.ts # Screenshot baselines
│ ├── fixtures/
│ │ └── auth.ts # Shared authentication fixtures
│ ├── pages/
│ │ ├── LoginPage.ts # Page object for /login
│ │ └── DashboardPage.ts # Page object for /dashboard
│ └── playwright.config.ts # Browser projects, timeoutsCI/CD Integration
# .github/workflows/e2e.yml
name: E2E Tests
on:
pull_request:
branches: [main]
schedule:
- cron: '0 6 * * *' # Daily smoke test
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run E2E tests
run: npx playwright test --project=chromium
env:
DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report/
retention-days: 30Common Mistakes
| Mistake | Why It's Wrong | Correct Approach |
| Testing every single page | Slow, high maintenance | Cover critical flows, unit test the rest |
waitForTimeout(5000) everywhere | Flaky on variable load times | Wait for specific selectors/state |
| Hardcoded credentials in tests | Security risk, not portable | Use env vars + fixtures for auth |
| Tests sharing state | Order dependency, cascading failures | Each test creates its own data |
| No cleanup after tests | Database grows, tests slow down | Use transaction rollback or per-test schemas |
| Screenshot tests on dynamic content | Every run differs | Mock dates, random values, or use maxDiffPixels |
Best Practices
- Test critical flows only — E2E tests are expensive; unit tests are cheap
- Use Page Object Model — keeps tests readable and maintainable
- Mock external APIs — deterministic results, no network dependency
- Wait for state, not time —
expect(locator).toBeVisible()notwaitForTimeout() - Use semantic selectors —
getByRole(),getByTestId(), not CSS classes - Parallelize aggressively —
fullyParallel: true, independent test data - Capture traces on failure —
trace: 'on-first-retry'for debugging - Run daily in CI — catch regressions before they reach production
- Keep tests under 30 seconds each — slow tests indicate wrong abstraction
- Review flaky tests weekly — fix or delete, never ignore
Success Metrics
- All P0 and P1 critical flows covered by E2E tests
- Flaky test rate < 2% (failures per run)
- E2E suite completes in under 10 minutes
- Visual regression baselines updated after intentional UI changes
- Cross-browser tests pass on Chromium, Firefox, WebKit
- No hardcoded credentials or secrets in test files
- Test results visible in CI/CD pipeline with artifact upload on failure
Remember: E2E tests are your last line of automated defense. They should be reliable, fast, and focused on what matters to real users.
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
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.

