agentleFS
bkjain655bkjain655/agent-skills/skills/playwright-e2e-testing/SKILL.md

playwright-e2e-testing

Skill0 starsChanged 3 months agoMITView on GitHub

End-to-end testing with Playwright in Next.js: config, webServer, helpers, localStorage seeding, accessibility scans, and CI. Use when adding E2E tests, smoke tests, or browser automation for React webapps.

  • Reads credentials
  • Installs packages

8 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use api-and-interface-design, receiving-code-review and 1 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.
  • LLl0k0laDSkill

    api-and-interface-design

    Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

    Also in 3 projects that use this

  • CloudflareSkill

    receiving-code-review

    Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation

    Also in 3 projects that use this

  • OpenAISkill

    requesting-code-review

    Use when completing tasks, implementing major features, or before merging to verify work meets requirements

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Prefer getByRole, getByLabel over CSS selectors.

    line 59
  2. Very specific:

    Use before goto for dashboard tests requiring completed setup.

    line 72
  3. Very specific:

    Run build && start in CI via webServer config — avoids dev-server flakiness.

    line 96

“Common” is measured: kept by at least 6 in 10 of the 5 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

Playwright E2E Testing

Install

npm install -D @playwright/test
npx playwright install chromium

Config (playwright.config.ts)

import { defineConfig, devices } from "@playwright/test";

const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? "http://localhost:3000";

export default defineConfig({
  testDir: "./e2e",
  fullyParallel: true,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  use: { baseURL, trace: "on-first-retry" },
  projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
  webServer: {
    command: process.env.CI ? "npm run build && npm run start" : "npm run dev",
    url: baseURL,
    reuseExistingServer: !process.env.CI,
    timeout: 180_000,
  },
});

Package scripts

"test:e2e": "playwright test"

Basic spec

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

test("homepage navigates to signup", async ({ page }) => {
  await page.goto("/");
  await page.getByRole("link", { name: /Get Started/i }).click();
  await expect(page).toHaveURL(/\/signup/);
});

Prefer getByRole, getByLabel over CSS selectors.

Seed client state (localStorage)

// e2e/helpers/seed-store.ts
export async function seedStore(page: Page, snapshot: object) {
  await page.addInitScript((data) => {
    localStorage.setItem("app-storage-key", JSON.stringify({ state: data, version: 0 }));
  }, snapshot);
}

Use before goto for dashboard tests requiring completed setup.

Accessibility scan

npm install -D @axe-core/playwright
import AxeBuilder from "@axe-core/playwright";

const results = await new AxeBuilder({ page }).withTags(["wcag2aa"]).analyze();
expect(results.violations).toEqual([]);

CI (GitHub Actions)

- run: npx playwright install chromium --with-deps
- run: npm run test:e2e
  env:
    CI: true

Run build && start in CI via webServer config — avoids dev-server flakiness.

Tips

IssueFix
Parallel workers clash on buildworkers: 1 in CI
Hydration timingawait expect(locator).toBeVisible()
DialogsgetByRole("dialog")
File uploadsetInputFiles on hidden input

Anti-patterns

  • Hard-coded waitForTimeout instead of assertions
  • Testing implementation details (class names) over roles
  • Sharing mutable state between parallel tests
  • Skipping browser install step in CI

Pair with: web-accessibility-wcag, vitest-unit-testing.

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.