mcpbeat Sign in

Playwright E2e Tester Agent Skill

Expert in end-to-end testing with Playwright, the modern cross-browser testing framework. Specializes in test generation, page object patterns, visual regression testing, and CI/CD integration. Handles complex testing scenarios including authentication flows, API mocking, and mobile emulation.

2k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
177
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/curiositech/some_claude_skills --skill playwright-e2e-tester

The instruction itself

19 sections, as written by the author

Playwright E2E Tester

Overview

Expert in end-to-end testing with Playwright, the modern cross-browser testing framework. Specializes in test generation, page object patterns, visual regression testing, and CI/CD integration. Handles complex testing scenarios including authentication flows, API mocking, and mobile emulation.

When to Use

  • Setting up Playwright in a new or existing project
  • Writing E2E tests for critical user flows
  • Debugging flaky tests or test failures
  • Implementing visual regression testing
  • Configuring Playwright for CI/CD pipelines
  • Migrating from Cypress, Selenium, or Puppeteer
  • Testing authenticated flows with session management
  • Cross-browser testing (Chromium, Firefox, WebKit)

Capabilities

Test Generation & Writing

  • Generate Playwright tests from user stories or acceptance criteria
  • Write tests using best practices (locators, assertions, waits)
  • Implement Page Object Model (POM) patterns
  • Create reusable test fixtures and utilities
  • Handle dynamic content and race conditions

Configuration & Setup

  • Configure playwright.config.ts for different environments
  • Set up projects for multiple browsers and viewports
  • Configure base URL, timeouts, and retries
  • Implement global setup/teardown for auth
  • Set up test reporters (HTML, JSON, JUnit)

Advanced Patterns

  • API mocking with route() and fulfill()
  • Network interception and request validation
  • Visual regression with toHaveScreenshot()
  • Accessibility testing with @axe-core/playwright
  • Mobile emulation and device testing
  • Geolocation and permissions mocking

CI/CD Integration

  • GitHub Actions workflow configuration
  • Parallel test execution with sharding
  • Artifact collection (traces, screenshots, videos)
  • Flaky test detection and retry strategies
  • Test result reporting and notifications

Debugging & Maintenance

  • Use Playwright Inspector and Trace Viewer
  • Debug with page.pause() and headed mode
  • Analyze test traces for failures
  • Reduce test flakiness with proper waits
  • Maintain test stability over time

Dependencies

Works well with:

  • vitest-testing-patterns - Unit test patterns that complement E2E
  • github-actions-pipeline-builder - CI/CD pipeline setup
  • accessibility-auditor - Extended accessibility testing
  • api-architect - API contract testing alongside E2E

Examples

Basic Test Structure

import { test, expect } from '@playwright/test';

test.describe('User Authentication', () => {
  test('should allow user to sign in', async ({ page }) => {
    await page.goto('/login');

    await page.getByLabel('Email').fill('[email protected]');
    await page.getByLabel('Password').fill('securepassword');
    await page.getByRole('button', { name: 'Sign In' }).click();

    await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
    await expect(page).toHaveURL('/dashboard');
  });
});

Page Object Pattern

// pages/LoginPage.ts
import { Page, Locator } from '@playwright/test';

export class LoginPage {
  readonly page: Page;
  readonly emailInput: Locator;
  readonly passwordInput: Locator;
  readonly signInButton: Locator;

  constructor(page: Page) {
    this.page = page;
    this.emailInput = page.getByLabel('Email');
    this.passwordInput = page.getByLabel('Password');
    this.signInButton = page.getByRole('button', { name: 'Sign In' });
  }

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

  async signIn(email: string, password: string) {
    await this.emailInput.fill(email);
    await this.passwordInput.fill(password);
    await this.signInButton.click();
  }
}

Auth Setup Fixture

// fixtures/auth.ts
import { test as base } from '@playwright/test';

export const test = base.extend({
  authenticatedPage: async ({ page }, use) => {
    // Perform authentication
    await page.goto('/login');
    await page.getByLabel('Email').fill(process.env.TEST_USER!);
    await page.getByLabel('Password').fill(process.env.TEST_PASS!);
    await page.getByRole('button', { name: 'Sign In' }).click();

    // Wait for auth to complete
    await page.waitForURL('/dashboard');

    // Use the authenticated page in tests
    await use(page);
  },
});

GitHub Actions CI

name: E2E Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Install dependencies
        run: npm ci

      - name: Install Playwright browsers
        run: npx playwright install --with-deps

      - name: Run E2E tests
        run: npx playwright test

      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-report
          path: playwright-report/

Visual Regression Test

test('homepage matches snapshot', async ({ page }) => {
  await page.goto('/');

  // Full page screenshot comparison
  await expect(page).toHaveScreenshot('homepage.png', {
    fullPage: true,
    maxDiffPixelRatio: 0.01,
  });

  // Component-level screenshot
  const hero = page.getByTestId('hero-section');
  await expect(hero).toHaveScreenshot('hero-section.png');
});

API Mocking

test('displays products from API', async ({ page }) => {
  // Mock the API response
  await page.route('**/api/products', async (route) => {
    await route.fulfill({
      status: 200,
      contentType: 'application/json',
      body: JSON.stringify([
        { id: 1, name: 'Product A', price: 29.99 },
        { id: 2, name: 'Product B', price: 49.99 },
      ]),
    });
  });

  await page.goto('/products');

  await expect(page.getByText('Product A')).toBeVisible();
  await expect(page.getByText('$29.99')).toBeVisible();
});

Best Practices

  • Use role-based locators - Prefer getByRole(), getByLabel(), getByText() over CSS selectors
  • Avoid hard waits - Use waitForSelector(), waitForURL(), or assertions instead of waitForTimeout()
  • Isolate tests - Each test should be independent and not rely on state from other tests
  • Use fixtures - Share setup logic through fixtures rather than beforeEach hooks
  • Keep tests focused - Test one user flow per test, avoid testing multiple unrelated things
  • Handle flakiness proactively - Use proper waits, retries, and stable locators
  • Organize with Page Objects - Encapsulate page interactions for maintainability
  • Run in CI - Always run E2E tests in CI before merging

Common Pitfalls

  • Flaky locators: Avoid fragile selectors like nth-child(3) or auto-generated class names
  • Race conditions: Always wait for elements/navigation before interacting
  • Shared state: Tests should not depend on execution order
  • Slow tests: Use API calls to set up state instead of UI interactions when possible
  • Missing cleanup: Clean up test data to avoid pollution between runs

Other skills for the same job

different authors, same section of the catalogue
Webapp Testing
by anthropics
vendor ×12

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

6k tokens scripts
Azure Microsoft Playwright Testing Ts
by lingxling
×1

Run Playwright tests at scale with cloud-hosted browsers and integrated Azure portal reporting.

2k tokens
Chrome Devtools
by christophacham
×1

Browser debugging, performance profiling, and automation via Chrome DevTools MCP. Use when user says "debug this page", "take a screenshot", "check network requests", "profile performance", "inspect console errors", or "analyze page load". Do NOT use for full E2E test suites (use playwright-skill) or non-browser debugging.

1k tokens
QA
by browser-use

QA-test a website or web app and return a 1-5 quality score (5 = flawless, 1 = broken) with evidence. Use when the user wants to test, QA, evaluate, score, or "check how good" a site, page, flow, or app — including a local dev server (e.g. "qa test localhost:5173", "does the checkout work?", "rate this landing page"). Drives a real Browser Use cloud browser, tunneling localhost automatically.

9k tokens
Playwright Component Testing
by microsoft
vendor

Set up component testing with Playwright using a story gallery — scaffold stories and a gallery dev page driven by the built-in mount fixture, no dedicated component-testing runtime. Use when asked to test React or Vue components in isolation with Playwright, or to migrate off @playwright/experimental-ct-react / -vue.

8k tokens scripts
Browser Testing With Devtools
by addyosmani

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

4k tokens
Browser Harness
by browser-use

Always use browser-harness for any web interaction: automation, scraping, testing, or site/app work.

493k tokens scripts
Help Center UI Test
by Automattic

Run a browser-based UI review of the WordPress.com Help Center across multiple surfaces, looking for visual and behavioral issues. Use when asked to test the Help Center UI.

2k tokens

How to use it

Copy the folder

Take curiositech/playwright-e2e-tester from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.

Install what it needs

The instructions reference npx. Without those the skill loads but fails at the first command.