agentleFS
infeniainfenia/yukta/.claude/skills/playwright/SKILL.md

playwright

Skill1 starsChanged 20 days agoApache-2.0View on GitHub

Write E2E tests for Yukta UI using Playwright and MSW mocking. Tests run against mocked APIs with no backend calls needed.

99 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use develop-web-game, msw and 10 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.
  • hebertzhuSkill

    develop-web-game

    Use when building or iterating on a web game and you need a tight implement-test-observe loop; prefer the bundled Playwright client, inspect screenshots and text state, and validate every meaningful change before moving on.

    Also in 4 projects that use this

  • thongdn-itSkill

    msw

    MSW (Mock Service Worker) best practices for API mocking in tests (formerly test-msw). This skill should be used when setting up MSW, writing request handlers, or mocking HTTP APIs. This skill does NOT cover general testing patterns (use test-vitest or test-tdd skills) or test methodology.

    Also in 3 projects that use this

  • SupabaseSkill

    react-hook-form

    Correct React Hook Form usage anywhere in the monorepo — data flow, subscriptions,

    Also in 3 projects that use this

  • thongdn-itSkill

    tailwind

    Tailwind CSS v4 performance optimization and best practices guidelines (formerly tailwindcss-v4-style). This skill should be used when writing, reviewing, or refactoring Tailwind CSS v4 code to ensure optimal build performance, minimal CSS output, and correct usage of v4 features. Triggers on tasks involving Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.

    Also in 5 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 6 projects that use this

  • OpenAISkill

    web-perf

    Analyzes web performance using Chrome DevTools MCP. Measures Core Web Vitals (FCP, LCP, TBT, CLS, Speed Index), identifies render-blocking resources, network dependency chains, layout shifts, caching issues, and accessibility gaps. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed. Biases towards retrieval from current documentation over pre-trained knowledge.

    Also in 5 projects that use this

  • +1 more from thongdn-it

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 83 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

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

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

    Write comprehensive E2E tests for the Yukta UI application using Playwright and MSW mocking.

    line 10
  2. Very specific:

    Use page.waitForTimeout() — use semantic waits instead

    line 121
  3. Distinctive:

    Use fragile selectors — prefer data-testid

    line 124
  4. Very specific:

    Use semantic waits: waitForLoadingComplete(), waitForApiResponse()

    line 127
  5. Very specific:

    Use fixture data: mockSessions

    line 128
  6. Distinctive:

    Test user-visible behavior, not implementation

    line 130
  7. Distinctive:

    Follow patterns from Core Patterns section above

    line 150
  8. Distinctive:

    Add handler following existing pattern (timestamp, status, data)

    line 156
  9. Very specific:

    Use in tests: await waitForApiResponse(page, { url: '/api/new' })

    line 158

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

Write comprehensive E2E tests for the Yukta UI application using Playwright and MSW mocking.

Quick Reference

Test Data Available

// From fixtures
mockSessions: [
  { sessionId: 'session-1', name: 'Build Pipeline', ... },
  { sessionId: 'session-2', name: 'Code Review', ... },
  { sessionId: 'session-3', name: 'Data Pipeline', ... },
]

Essential Utilities

import { test, expect } from '../fixtures';
import {
  waitForApiResponse,
  fillForm,
  waitForLoadingComplete,
  getTableRow,
  countTableRows,
  assertTableColumns,
  clickAndWait,
  getTextContent,
} from '../utils';

Common Commands

pnpm test:e2e                        # All tests
pnpm test:e2e tests/file.spec.ts     # Specific file
pnpm test:e2e --grep "pattern"       # Match pattern
pnpm test:e2e --headed               # See browser
pnpm test:e2e --debug                # Interactive debug

Core Patterns

List Page Test

test('should display sessions', async ({ page, mockSessions }) => {
  await page.goto('/');
  await waitForLoadingComplete(page);
  
  const rowCount = await countTableRows(page);
  expect(rowCount).toBe(mockSessions.length);
});

API Error Test

test('should handle error', async ({ page }) => {
  // Register waiter BEFORE navigation
  const responsePromise = waitForApiResponse(page, { url: '/api/sessions/summaries' });
  
  // Then navigate
  await page.goto('/?error=true');
  
  // Await the response
  const response = await responsePromise;
  expect(response.status()).toBe(500);
});

Form Test

test('should submit form', async ({ page }) => {
  await fillForm(page, { 'Name': 'Session', 'Description': 'Test' });
  await clickAndWait(page, 'button[type="submit"]', {
    waitForResponse: '/api/sessions',
  });
});

Navigation Test

test('should navigate to details', async ({ page }) => {
  const row = await getTableRow(page, 'Build Pipeline');
  await clickAndWait(page, row.locator('a'), {
    waitForUrl: '/sessions/**',
  });
});

Selector Priority

  1. data-testid (most stable)
    page.locator('[data-testid="submit"]')
  2. Accessible roles
    page.getByRole('button', { name: 'Submit' })
  3. Labels
    page.getByLabel('Email')
  4. Text (last resort)
    page.getByText('Sessions')

Critical Rules

❌ NEVER

  • Use page.waitForTimeout() — use semantic waits instead
  • Hardcode test data — use mockSessions fixture
  • Depend on test order — each test must be independent
  • Use fragile selectors — prefer data-testid

✅ ALWAYS

  • Use semantic waits: waitForLoadingComplete(), waitForApiResponse()
  • Use fixture data: mockSessions
  • Setup in beforeEach() — avoid repetition
  • Test user-visible behavior, not implementation

File Structure

e2e/
├── fixtures.ts                 # Test data & imports
├── utils.ts                    # 15+ helper functions
├── mocks/handlers.ts           # API mocks (extensible)
└── tests/
    ├── session-list.spec.ts    # Reference: 26 tests
    ├── error-handling.spec.ts  # Reference: 8 tests
    └── theme.spec.ts           # Reference: 6 tests

Workflow

Writing New Tests

  1. Create file: e2e/tests/feature-name.spec.ts
  2. Copy template from e2e/tests/session-list.spec.ts
  3. Follow patterns from Core Patterns section above
  4. Run: pnpm test:e2e tests/feature-name.spec.ts --headed
  5. Debug with --debug if failing

Adding API Endpoints

  1. Open: e2e/mocks/handlers.ts
  2. Add handler following existing pattern (timestamp, status, data)
  3. Export in handlers array (automatic)
  4. Use in tests: await waitForApiResponse(page, { url: '/api/new' })

Application Routes

  • / — Session list (main page)
  • /sessions/:id — Session details
  • /sessions/:id/workflow/:wid — Workflow view
  • /control — Control bus
  • /history — History

Test Checklist

  • Test name describes expected behavior
  • Setup in beforeEach(), not repeated
  • Uses mockSessions fixture, not hardcoded
  • Uses semantic waits (no waitForTimeout)
  • Uses stable selectors (data-testid preferred)
  • Specific assertions (not generic checks)
  • Test is independent (no dependencies)
  • Error scenarios covered (if applicable)
  • Runs in < 5 seconds
  • Passes locally: pnpm test:e2e --grep "name"

Screenshot Tests

Visual regression testing included in e2e/tests/screenshots.spec.ts:

# Run only screenshot tests
pnpm test:e2e screenshots.spec.ts

# Update baseline screenshots
UPDATE_SNAPSHOTS=true pnpm test:e2e screenshots.spec.ts

# View screenshot diffs
pnpm exec playwright show-report

Covers:

  • Full page layout (desktop, tablet, mobile)
  • Dark/light mode themes
  • Component states (hover, error, empty)
  • Responsive breakpoints
  • UI component details

Stored in: e2e/__snapshots__/

CI Integration

Tests run automatically when PR changes ui/ module:

  • Triggered by GitHub Actions on PR
  • Fails if screenshots don't match baseline (use UPDATE_SNAPSHOTS=true to update)
  • Results posted to PR comments
  • Reports uploaded as artifacts

Reference Files

  • Guide: ui/.claude/playwright-testing-guide.md — Detailed patterns
  • Examples: e2e/tests/session-list.spec.ts — 26 reference tests
  • Screenshots: e2e/tests/screenshots.spec.ts — Visual regression tests
  • Utilities: e2e/utils.ts — All helper functions with docs
  • Handlers: e2e/mocks/handlers.ts — API mocks (extensible)
  • Fixtures: e2e/fixtures.ts — Test data setup
  • Config: playwright.config.ts — Framework settings

Session Model

interface SessionListItem {
  sessionId: string;
  name: string;
  description: string;
  initiator: string;
  tags: string[];
  projectPath: string;
  workflowCount: number;
}

API Response Format

All mocked responses:

{
  timestamp: string,       // ISO format
  status: number,          // 200, 201, 500, etc
  message: string,         // Human readable
  path: string,            // Request path
  data: T,                 // Actual response data ← use this
  error?: string,
  errors?: Record<string, string[]>,
}

Debugging

# Interactive step-through
pnpm test:e2e --debug

# See browser + slow motion
pnpm test:e2e --headed --slow-mo=1000

# View HTML report
pnpm exec playwright show-report

# Specific test only
pnpm test:e2e --grep "exact test name"

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.