Token导航 LogoToken导航

Agent Skill · 前端设计

playwright-testing(Playwright 测试)

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

playwright-testing 是前端设计类 Agent Skill,可用宿主为 Local Agent,通过unknown获取,权限为接触敏感数据;许可证信息还不明确,暂无第三方扫描结果,按安装量在前端设计类的 10,216 个 Skill 里排第 8,708。

总安装 267周安装 11下载 87核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:playwright-testing(Playwright 测试)
来源仓库:https://smithery.ai
仓库路径:playwright-testing
安装命令:
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。当前暂无明确安装命令,请以来源页面说明为准。

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

用于辅助测试设计、自动化测试和用例整理。playwright-testing 属于前端设计类 Skill,可作为该场景下的辅助能力补充。适合编写单元测试、端到端测试或根据日志定位问题。需确认项目测试框架、运行命令和夹具数据后使用。避免为通过测试而修改真实逻辑,区分模拟与生产环境。

涉及浏览器或服务时,应明确本地、测试和生产环境边界。

来源仓库内路径:playwright-testing

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Local Agent;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    没有现成安装命令,按unknown的说明从来源页面获取,仓库路径是 playwright-testing。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

playwright-testing 怎么安装?

公开资料没有给出可以直接复制的命令,需要按来源页面说明手动安装,仓库内路径为 playwright-testing。

playwright-testing 支持哪些 AI 工具?

公开资料标注支持 Local Agent。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

playwright-testing 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

playwright-testing 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

playwright-testing 用的人多吗?

公开数据是累计安装 267 次,近一周安装 11 次,下载 87 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

playwright-testing 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

值得选的地方和要先想清楚的地方

值得选的地方

  • 专注 Local Agent 一种宿主,触发方式和使用习惯不用来回切换。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Local Agent,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 要求有安全扫描结论才肯安装的团队。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
playwright-testing

Playwright 测试 · 本页

267—接触敏感数据未明确未收录

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Playwright Testing

Overview

To build reliable, maintainable end-to-end tests for modern web applications, follow Playwright best practices with TypeScript, Page Object Model patterns, and automated CI/CD integration. This skill provides comprehensive guidance for testing SPAs (React, Vue, Angular) and traditional web applications using Playwright's powerful automation capabilities.

Current Playwright Version: 1.48+ (as of 2025) Language: TypeScript with strict typing Test Runner: Playwright Test (@playwright/test) CI/CD: GitHub Actions, Docker support Standard Patterns: Page Object Model, Fixtures, Component Testing

Decision Tree: Choosing Your Testing Approach

User Request → What type of test are you creating?
    |
    ├─ End-to-end user flow test?
    │   ├─ Single page interaction? → Use Quick Start: Basic Test
    │   └─ Multi-page workflow? → Use Page Object Model Pattern
    │
    ├─ Component testing in isolation?
    │   └─ Load references/component-testing-guide.md
    │
    ├─ Visual regression testing?
    │   └─ Load references/visual-testing-guide.md
    │
    ├─ Setting up new Playwright project?
    │   └─ Run scripts/init-playwright.ts
    │
    ├─ Creating reusable page objects?
    │   ├─ Run scripts/generate-page-object.ts for scaffolding
    │   └─ Load references/page-object-patterns.md for patterns
    │
    ├─ Debugging flaky tests?
    │   └─ Load references/anti-patterns.md
    │
    ├─ Optimizing test selectors?
    │   └─ Load references/locator-strategies.md
    │
    └─ Setting up CI/CD pipeline?
        └─ Use assets/workflows/playwright-tests.yml

Quick Start: Basic Test

Simple Test with TypeScript

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

test('user can login successfully', async ({ page }) => {
  // Navigate to application
  await page.goto('https://app.example.com');

  // Interact with elements using recommended locators
  await page.getByLabel('Email').fill('user@example.com');
  await page.getByLabel('Password').fill('SecurePass123');
  await page.getByRole('button', { name: 'Sign in' }).click();

  // Assert expected outcomes
  await expect(page).toHaveURL('/dashboard');
  await expect(page.getByRole('heading', { name: 'Welcome back' })).toBeVisible();
});

Test with Multiple Assertions

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

test.describe('Shopping Cart', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/products');
  });

  test('add item to cart', async ({ page }) => {
    // Find and click product
    const product = page.getByRole('article').filter({ hasText: 'Premium Headphones' });
    await product.getByRole('button', { name: 'Add to cart' }).click();

    // Verify cart updated
    await expect(page.getByTestId('cart-count')).toHaveText('1');

    // Navigate to cart
    await page.getByRole('link', { name: 'Cart' }).click();

    // Verify item in cart
    await expect(page.getByRole('heading', { name: 'Premium Headphones' })).toBeVisible();
    await expect(page.getByText('$199.99')).toBeVisible();
  });
});

Workflow: Creating Comprehensive Test Suites

Follow this structured approach to build maintainable test suites for your application.

Step 1: Analyze Application Structure

To begin testing effectively:

  1. Map user journeys: Identify critical paths users take
  2. Identify page boundaries: Determine logical page groupings
  3. List reusable components: Find common UI patterns
  4. Document test data needs: Understand data dependencies

Step 2: Set Up Project Structure

Initialize your Playwright project with proper TypeScript configuration:

# Run initialization script
npx tsx scripts/init-playwright.ts

This creates:

  • TypeScript configuration with strict typing
  • Playwright config with parallel execution
  • Base fixture setup
  • Initial folder structure

Step 3: Implement Page Objects

Create page objects for reusable, maintainable tests:

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

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

  constructor(page: Page) {
    this.page = page;
    this.emailInput = page.getByLabel('Email');
    this.passwordInput = page.getByLabel('Password');
    this.submitButton = page.getByRole('button', { name: 'Sign in' });
    this.errorMessage = page.getByRole('alert');
  }

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

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

  async expectError(message: string) {
    await expect(this.errorMessage).toContainText(message);
  }
}

Use the page object generator for scaffolding:

npx tsx scripts/generate-page-object.ts --url="/login" --name="LoginPage"

Step 4: Write Test Scenarios

Structure tests using Given-When-Then pattern:

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

test.describe('Authentication', () => {
  let loginPage: LoginPage;

  test.beforeEach(async ({ page }) => {
    loginPage = new LoginPage(page);
    await loginPage.goto();
  });

  test('successful login redirects to dashboard', async ({ page }) => {
    // Given: Valid user credentials
    const email = 'user@example.com';
    const password = 'ValidPass123';

    // When: User attempts to login
    await loginPage.login(email, password);

    // Then: User is redirected to dashboard
    await expect(page).toHaveURL('/dashboard');
  });

  test('invalid credentials show error', async () => {
    // When: User enters invalid credentials
    await loginPage.login('bad@email.com', 'wrong');

    // Then: Error message is displayed
    await loginPage.expectError('Invalid email or password');
  });
});

Step 5: Implement Visual Testing

Add visual regression tests for UI consistency:

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

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

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

  // Component screenshot
  const header = page.getByRole('banner');
  await expect(header).toHaveScreenshot('header.png');
});

Update baselines when intentional changes are made:

npx tsx scripts/visual-baseline.ts --update

Step 6: Configure CI/CD

Deploy the GitHub Actions workflow for automated testing:

# .github/workflows/playwright.yml
name: Playwright Tests
on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npm run test:e2e
      - uses: actions/upload-artifact@v4
        if: failure()
        with:
          name: playwright-report
          path: playwright-report/

Core Testing Principles

1. Test User Behavior, Not Implementation

Write tests from the user's perspective:

// ✅ Good: Tests user-visible behavior
await page.getByRole('button', { name: 'Submit order' }).click();
await expect(page.getByText('Order confirmed')).toBeVisible();

// ❌ Bad: Tests implementation details
await page.locator('#submit-btn-2947').click();
await expect(page.locator('.success-msg-div')).toHaveClass('visible');

2. Use Semantic Locators

Prefer accessible, semantic locators that won't break with styling changes:

// Priority order for locators:
// 1. User-facing attributes
await page.getByRole('button', { name: 'Save' });
await page.getByLabel('Email address');
await page.getByPlaceholder('Search products...');
await page.getByText('Welcome back');

// 2. Test IDs (when needed for complex elements)
await page.getByTestId('product-card-12345');

// 3. CSS/XPath (avoid when possible)
await page.locator('css=.dynamic-content'); // Last resort

3. Isolate Test State

Each test should run independently:

test.describe('User Profile', () => {
  // Create fresh user for each test
  test.beforeEach(async ({ page, request }) => {
    const user = await createTestUser(request);
    await authenticateUser(page, user);
  });

  test.afterEach(async ({ request }, testInfo) => {
    // Cleanup test data
    await cleanupTestUser(request, testInfo);
  });

  test('update profile name', async ({ page }) => {
    // Test runs with isolated user
  });
});

4. Handle Asynchronous Operations

Playwright auto-waits, but be explicit when needed:

// Auto-wait handles most cases
await page.getByRole('button', { name: 'Load data' }).click();
await expect(page.getByTestId('data-table')).toBeVisible();

// Explicit wait for specific conditions
await page.waitForResponse(resp =>
  resp.url().includes('/api/data') && resp.status() === 200
);

// Wait for network idle
await page.waitForLoadState('networkidle');

5. Implement Retry Logic Wisely

Configure retries for flaky scenarios, but investigate root causes:

// playwright.config.ts
export default defineConfig({
  retries: process.env.CI ? 2 : 0,
  use: {
    // Retry navigation on failure
    navigationTimeout: 30000,
    actionTimeout: 15000,
  },
});

// Per-test retry configuration
test('flaky integration test', async ({ page }) => {
  test.info().annotations.push({
    type: 'flaky',
    description: 'External API occasionally slow'
  });
  // Test implementation
});

Testing Modern SPAs

React Testing Patterns

// Wait for React to hydrate
await page.waitForFunction(() => window.React && window.React.version);

// Test React components
const component = page.getByTestId('user-list');
await expect(component).toBeVisible();
await expect(component.locator('[data-testid="user-item"]')).toHaveCount(5);

Vue Testing Patterns

// Wait for Vue app to mount
await page.waitForFunction(() => window.Vue && document.querySelector('#app').__vue__);

// Interact with Vue components
await page.getByRole('button', { name: 'Toggle' }).click();
await expect(page.getByTestId('toggle-state')).toHaveText('active');

Angular Testing Patterns

// Wait for Angular to bootstrap
await page.waitForFunction(() => window.getAllAngularTestabilities);

// Test Angular forms
await page.getByLabel('Username').fill('testuser');
await page.getByLabel('Email').fill('test@example.com');
await expect(page.getByRole('button', { name: 'Submit' })).toBeEnabled();

Quick Reference: Common Patterns

Authentication Flow

export async function authenticateUser(page: Page, credentials: UserCredentials) {
  await page.goto('/login');
  await page.getByLabel('Email').fill(credentials.email);
  await page.getByLabel('Password').fill(credentials.password);
  await page.getByRole('button', { name: 'Sign in' }).click();
  await page.waitForURL('/dashboard');
}

API Mocking

await page.route('**/api/users', async route => {
  await route.fulfill({
    status: 200,
    contentType: 'application/json',
    body: JSON.stringify([{ id: 1, name: 'Test User' }])
  });
});

File Upload

const fileInput = page.getByLabel('Upload file');
await fileInput.setInputFiles('path/to/file.pdf');
await expect(page.getByText('file.pdf')).toBeVisible();

Accessibility Testing

import { injectAxe, checkA11y } from 'axe-playwright';

test('page is accessible', async ({ page }) => {
  await page.goto('/');
  await injectAxe(page);
  await checkA11y(page, null, {
    detailedReport: true,
    detailedReportOptions: { html: true }
  });
});

Resources

This skill includes comprehensive reference materials and templates:

references/page-object-patterns.md

Advanced Page Object Model patterns including fixtures, page managers, composition patterns, and enterprise-scale organization strategies.

Load when: Implementing page objects, organizing large test suites, or creating reusable test components.

references/component-testing-guide.md

Guide for testing UI components in isolation for React, Vue, and Angular applications, including mounting strategies and state management.

Load when: Testing individual components, setting up component test harnesses, or testing component interactions.

references/visual-testing-guide.md

Visual regression testing strategies including screenshot comparison, viewport testing, cross-browser visual testing, and baseline management.

Load when: Implementing visual tests, managing screenshot baselines, or debugging visual differences.

references/locator-strategies.md

Modern selector strategies for reliable element location, including auto-waiting patterns, shadow DOM traversal, and dynamic content handling.

Load when: Writing resilient selectors, debugging flaky locators, or handling complex DOM structures.

references/anti-patterns.md

Common Playwright testing mistakes and how to avoid them, including test coupling, hard-coded waits, and improper assertion patterns.

Load when: Reviewing test quality, debugging failures, or training team members on best practices.

Scripts

  • init-playwright.ts: Initialize Playwright in existing project with TypeScript
  • generate-page-object.ts: Generate page object scaffolding from URL
  • visual-baseline.ts: Manage visual regression baselines

Templates

  • base-page.template.ts: Base page class with common functionality
  • component-test.template.ts: Component testing setup
  • fixture.template.ts: Custom fixture patterns
  • playwright.config.template.ts: Production-ready configuration

Tips for Success

  1. Start with critical paths: Test the most important user journeys first
  2. Use data-testid sparingly: Prefer semantic selectors, use test IDs only when necessary
  3. Run tests in parallel: Configure workers for faster execution
  4. Mock external dependencies: Use route handlers to control external services
  5. Review test reports: Analyze failures to identify patterns
  6. Keep tests focused: One test should verify one behavior
  7. Maintain test independence: Tests should not depend on execution order

When to Load Reference Files

To optimize context usage, load reference files strategically:

  • Load page-object-patterns.md when:

- Implementing Page Object Model - Creating reusable test utilities - Organizing large test suites - Need fixture patterns

  • Load component-testing-guide.md when:

- Testing components in isolation - Setting up component test environment - Working with framework-specific components

  • Load visual-testing-guide.md when:

- Implementing screenshot tests - Managing visual baselines - Setting up visual regression workflow

  • Load locator-strategies.md when:

- Writing complex selectors - Debugging flaky tests - Working with dynamic content

  • Load anti-patterns.md when:

- Reviewing existing tests - Training team members - Debugging test failures - Improving test quality

平台分布

Local Agent

88.03%
按下载量换算77

安全审计

暂无安全审计结果可展示。

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills