agentleFS
casooncasoon/ai-agent-config/skills/playwright/SKILL.md

playwright

Skill1 starsChanged 2 months agoMITView on GitHub

Playwright E2E test patterns for Astro — project setup, serving the static build, and ready-to-use specs for navigation, SEO meta, a11y (axe-core), i18n locales, contact forms, and theme toggling. Use when writing new E2E specs, debugging failing tests, setting up playwright.config.ts, or running `pnpm test:e2e`. Critical: tests run against the static dist/ build — always build first, and don't try to test SSR-only endpoints from E2E.

  • Reads credentials

55 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use doc, edit-article and 4 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.
  • JetBrainsSkill

    doc

    Use when the task involves reading, creating, or editing `.docx` documents, especially when formatting or layout fidelity matters; prefer `python-docx` plus the bundled `scripts/render_docx.py` for visual checks.

    Also in 5 projects that use this

  • kayamanSkill

    edit-article

    Edit and improve articles by restructuring sections, improving clarity, and tightening prose. Use when user wants to edit, revise, or improve an article draft.

    Also in 4 projects that use this

  • kennethkeimSkill

    ubiquitous-language

    Extract a DDD-style ubiquitous language glossary from the current conversation, flagging ambiguities and proposing canonical terms. Saves to UBIQUITOUS_LANGUAGE.md. Use when user wants to define domain terms, build a glossary, harden terminology, create a ubiquitous language, or mentions "domain model" or "DDD".

    Also in 4 projects that use this

  • qhkmSkill

    obsidian-vault

    Manage Obsidian vaults using built-in filesystem tools. Understands vault structure, frontmatter, wikilinks, tags, tasks, daily notes, and templates.

    Also in 4 projects that use this

  • kayamanSkill

    request-refactor-plan

    Guides creating a detailed refactor plan with tiny commits via user interview, then files it as a GitHub issue. Use when user wants to plan a refactor, create a refactoring RFC, or break a refactor into safe incremental steps.

    Also in 3 projects that use this

  • RoentekSkill

    writing-beats

    Writing, exploit — assemble raw material into a journey of beats, grounding each term before a beat leans on it.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 50 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Keep tests under e2e/, grouped per app or feature:

    line 10
  2. Distinctive:

    Run each app as its own Playwright project against the static build:

    line 25
  3. Very specific:

    Use descriptive test.describe groups.

    line 166
  4. Distinctive:

    Test both locales when the feature is i18n-aware.

    line 167

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

Project layout

Keep tests under e2e/, grouped per app or feature:

e2e/
  <app>/
    a11y.spec.ts
    navigation.spec.ts
    seo.spec.ts
    i18n.spec.ts
    theme.spec.ts
    forms.spec.ts

Configuration

Run each app as its own Playwright project against the static build:

// playwright.config.ts
export default defineConfig({
  testDir: './e2e',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  projects: [
    {
      name: 'site',
      use: { ...devices['Desktop Chrome'], baseURL: 'http://localhost:5173' },
      testMatch: 'site/**/*.spec.ts',
    },
  ],
  webServer: [
    { command: 'npx serve dist/client -l 5173', port: 5173, reuseExistingServer: false },
  ],
});

Tests require a build first. Web servers serve the static dist/client/ output — server-side features (form actions, sessions) are not exercisable from E2E against the static build.

Commands

pnpm test:e2e                         # everything
pnpm test:e2e --project=site          # single project
playwright test -g "SEO"              # filter by name
playwright test --ui                  # interactive runner

Test patterns

Navigation

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

test.describe('Navigation', () => {
  test('homepage renders', async ({ page }) => {
    await page.goto('/');
    await expect(page).toHaveTitle(/.+/);
    await expect(page.locator('h1')).toBeVisible();
  });

  test('contact link works', async ({ page }) => {
    await page.goto('/');
    await page.click('a[href="/contact"]');
    await expect(page).toHaveURL('/contact');
  });
});

SEO

test('homepage has OG meta tags', async ({ page }) => {
  await page.goto('/');
  await expect(page.locator('meta[property="og:title"]')).toHaveAttribute('content', /./);
  await expect(page.locator('meta[property="og:image"]')).toHaveAttribute('content', /\.png$/);
});

test('robots.txt contains Sitemap', async ({ page }) => {
  const res = await page.goto('/robots.txt');
  expect(res?.status()).toBe(200);
  expect(await res?.text()).toContain('Sitemap:');
});

test('sitemap is valid XML', async ({ page }) => {
  const res = await page.goto('/sitemap.xml');
  expect(res?.status()).toBe(200);
  expect(await res?.text()).toContain('<urlset');
});

test('JSON-LD present', async ({ page }) => {
  await page.goto('/');
  const jsonLd = page.locator('script[type="application/ld+json"]').first();
  await expect(jsonLd).toBeAttached();
  const parsed = JSON.parse((await jsonLd.textContent())!);
  expect(parsed['@context']).toBe('https://schema.org');
});

Accessibility (axe-core)

import AxeBuilder from '@axe-core/playwright';

test('homepage has no a11y violations', async ({ page }) => {
  await page.goto('/');
  const results = await new AxeBuilder({ page })
    .withTags(['wcag2a', 'wcag2aa', 'wcag22aa'])
    .analyze();
  expect(results.violations).toEqual([]);
});

i18n

test('german homepage has lang="de"', async ({ page }) => {
  await page.goto('/de');
  await expect(page.locator('html')).toHaveAttribute('lang', 'de');
});

test('language switcher navigates', async ({ page }) => {
  await page.goto('/');
  await page.click('a:has-text("DE")');
  await expect(page).toHaveURL('/de');
});

Forms

test('contact form renders all fields', async ({ page }) => {
  await page.goto('/contact');
  await expect(page.locator('input[name="name"]')).toBeVisible();
  await expect(page.locator('input[name="email"]')).toBeVisible();
  await expect(page.locator('textarea[name="message"]')).toBeVisible();
  await expect(page.locator('button[type="submit"]')).toBeVisible();
});

Theme toggle

test('theme toggle flips dark class', async ({ page }) => {
  await page.goto('/');
  const html = page.locator('html');
  const toggle = page.locator('button[aria-label*="dark" i], button[aria-label*="light" i]');
  await toggle.click();
  await expect(html).toHaveClass(/dark/);
});

Writing new tests

  1. Use descriptive test.describe groups.
  2. Test both locales when the feature is i18n-aware.
  3. For SEO tests, verify OG tags, canonical URLs, meta descriptions.
  4. For a11y tests, use AxeBuilder and expect zero violations.
  5. Build before running — E2E serves dist/client/, not the dev server.

Common mistakes

  • Forgetting to build first — tests run against the static output.
  • page.waitForNavigation() — prefer await expect(page).toHaveURL(...).
  • Hardcoding ports — use relative URLs; baseURL is set per project.
  • Testing server-only logic — E2E cannot exercise SSR-only endpoints when running against a static build.

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.