AGENT SKILL

playwright

End-to-end testing with Playwright — generate, run, and debug E2E tests.

适用职业开发工程师
使用场景测试与质量
License 许可
MIT
最近更新
2026-11-01
Stars
★ 12
Forks
0

01 前言 Front Matter

name
playwright
description
End-to-end testing with Playwright — generate, run, and debug E2E tests.
allowed-tools
[ "Bash", "Read", "Write", "Edit", "Grep", "Glob" ]

03 SKILL.md 正文

Playwright E2E Testing

Generate and run Playwright end-to-end tests for web applications.

Prerequisites

npx playwright --version

If not installed:

npm init playwright@latest
# or add to existing project:
npm install -D @playwright/test && npx playwright install

Workflow

1. Analyze

Read the source files for the page/component to test. Understand routes, interactive elements, and expected behaviors.

2. Generate Test File

Create a test file following the project's existing patterns and directory structure.

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

test.describe('Feature Name', () => {
  test.beforeEach(async ({ page }) => {
    // Setup: navigate, authenticate, seed data
  });

  test('should do expected behavior', async ({ page }) => {
    // Arrange
    // Act
    // Assert
  });
});

3. Run Tests

npx playwright test <file>           # Run specific test file
npx playwright test --headed          # With visible browser
npx playwright test --ui              # Playwright UI mode
npx playwright test --trace on        # Capture trace for debugging

4. Debug Failures

  • Read error output carefully
  • Use --trace on and open trace viewer: npx playwright show-trace trace.zip
  • Take screenshots on failure: await page.screenshot({ path: 'debug.png' })
  • Use page.pause() for step-by-step debugging in headed mode

Capabilities

  • Navigation: page.goto(), URL assertions, redirect verification
  • Forms: page.fill(), page.selectOption(), page.check(), multi-step wizards
  • Assertions: expect(page).toHaveURL(), expect(locator).toBeVisible(), toHaveText()
  • Screenshots: page.screenshot(), full-page, element-level
  • Visual regression: expect(page).toHaveScreenshot() with thresholds
  • Accessibility: @axe-core/playwright, ARIA role selectors, keyboard navigation
  • Network: page.route() for mocking, page.waitForResponse() for API calls

Tips

  • Use data-testid attributes for stable selectors
  • Prefer user-visible text and ARIA roles over CSS selectors
  • Use test.step() for complex multi-step flows
  • Set baseURL in playwright.config.ts
  • Use page.waitForResponse() for async navigation
  • Place test files alongside existing test patterns in the project

04 同仓库更多 Skills

ariadoss
ariadoss/superskills

youtube

Download YouTube video transcripts when user provides a YouTube URL or asks to download/get/fetch a transcript from YouTube. Also use when user wants to transcribe or get captions/subtitles from a YouTube video.

图像与多媒体
★ 12
ariadoss
ariadoss/superskills

write-plan

Use when you have a spec or requirements for a multi-step task, before touching code. Produces an engineering plan complete with TDD tasks, DRY/SOLID/YAGNI principles, a required Test Plan & Verification section, and a coverage target — then auto-runs /plan-eng-review as an independent double-check before execution.

★ 12
ariadoss
ariadoss/superskills

worktrees

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification

★ 12
ariadoss
ariadoss/superskills

web-perf

Analyzes web performance using Chrome DevTools MCP. Measures Core Web Vitals (LCP, INP, CLS) and supplementary metrics (FCP, TBT, 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.

Skill与智能体开发
★ 12
ariadoss
ariadoss/superskills

verify

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

★ 12
ariadoss
ariadoss/superskills

validate-idea

Validate a business idea using the minimalist entrepreneur framework. Use when someone has a business idea and wants to test if it's worth pursuing before building anything.

★ 12