Chuyển đến nội dung
Skillpedia
Kiểm thử29k · #9477

pw-init

Skill này làm gì

Skill này khiến agent cài đặt và cấu hình Playwright cho dự án của bạn. Skill dành cho lập trình viên mới bắt đầu kiểm thử trình duyệt và muốn có một thiết lập chạy được nhanh chóng.

Khi nào nên dùng

  • ✓Khi bạn bắt đầu một dự án mới và muốn có kiểm thử trình duyệt ngay từ đầu.
  • ✓Khi dự án của bạn chưa có thiết lập kiểm thử đầu cuối.
  • ✓Khi bạn muốn có sẵn một quy trình CI cho các kiểm thử trình duyệt.

Liên kết skill

https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/playwright-pro/skills/pw-init/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/playwright-pro/skills/pw-init/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy thiết lập Playwright trong dự án của tôi với một cấu hình cơ bản và một kiểm thử ví dụ.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent kiểm tra framework, ngôn ngữ và các thư mục kiểm thử hiện có của dự án. Sau đó nó cài Playwright, viết cấu hình phù hợp với framework và thêm một kiểm thử đầu tiên cùng quy trình CI.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Initialize Playwright Project

Set up a production-ready Playwright testing environment. Detect the framework, generate config, folder structure, example test, and CI workflow.

Steps

1. Analyze the Project

Use the Explore subagent to scan the project:

  • Check package.json for framework (React, Next.js, Vue, Angular, Svelte)
  • Check for tsconfig.json → use TypeScript; otherwise JavaScript
  • Check if Playwright is already installed (@playwright/test in dependencies)
  • Check for existing test directories (tests/, e2e/, __tests__/)
  • Check for existing CI config (.github/workflows/, .gitlab-ci.yml)

2. Install Playwright

If not already installed:

npm init playwright@latest -- --quiet

Or if the user prefers manual setup:

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

3. Generate playwright.config.ts

Adapt to the detected framework:

Next.js:

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

export default defineConfig({
  testDir: './e2e',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: [
    ['html', { open: 'never' }],
    ['list'],
  ],
  use: {
    baseURL: 'http://localhost:3000',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
  },
  projects: [
    { name: "chromium", use: { ...devices['Desktop Chrome'] } },
    { name: "firefox", use: { ...devices['Desktop Firefox'] } },
    { name: "webkit", use: { ...devices['Desktop Safari'] } },
  ],
  webServer: {
    command: 'npm run dev',
    url: 'http://localhost:3000',
    reuseExistingServer: !process.env.CI,
  },
});

React (Vite):

  • Change baseURL to http://localhost:5173
  • Change webServer.command to npm run dev

Vue/Nuxt:

  • Change baseURL to http://localhost:3000
  • Change webServer.command to npm run dev

Angular:

  • Change baseURL to http://localhost:4200
  • Change webServer.command to npm run start

No framework detected:

  • Omit webServer block
  • Set baseURL from user input or leave as placeholder

4. Create Folder Structure

e2e/
├── fixtures/
│   └── index.ts          # Custom fixtures
├── pages/
│   └── .gitkeep          # Page object models
├── test-data/
│   └── .gitkeep          # Test data files
└── example.spec.ts       # First example test

5. Generate Example Test

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

test.describe('Homepage', () => {
  test('should load successfully', async ({ page }) => {
    await page.goto('/');
    await expect(page).toHaveTitle(/.+/);
  });

  test('should have visible navigation', async ({ page }) => {
    await page.goto('/');
    await expect(page.getByRole('navigation')).toBeVisible();
  });
});

6. Generate CI Workflow

If .github/workflows/ exists, create playwright.yml:

name: "playwright-tests"

on:
  push:
    branches: [main, dev]
  pull_request:
    branches: [main, dev]

jobs:
  test:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: lts/*
      - name: "install-dependencies"
        run: npm ci
      - name: "install-playwright-browsers"
        run: npx playwright install --with-deps
      - name: "run-playwright-tests"
        run: npx playwright test
      - uses: actions/upload-artifact@v4
        if: ${{ !cancelled() }}
        with:
          name: "playwright-report"
          path: playwright-report/
          retention-days: 30

If .gitlab-ci.yml exists, add a Playwright stage instead.

7. Update .gitignore

Append if not already present:

/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

8. Add npm Scripts

Add to package.json scripts:

{
  "test:e2e": "playwright test",
  "test:e2e:ui": "playwright test --ui",
  "test:e2e:debug": "playwright test --debug"
}

9. Verify Setup

Run the example test:

npx playwright test

Report the result. If it fails, diagnose and fix before completing.

Output

Confirm what was created:

  • Config file path and key settings
  • Test directory and example test
  • CI workflow (if applicable)
  • npm scripts added
  • How to run: npx playwright test or npm run test:e2e
Câu hỏi thường gặp

Skill thích ứng với những framework nào?

Skill có ghi chú thiết lập cho các framework như Next.js, React, Vue, Angular và Svelte.

Nếu tôi đã có một số kiểm thử thì sao?

Skill kiểm tra trước các thư mục kiểm thử và bản cài Playwright đã có, nên nó khớp với những gì bạn đang có.

Nếu tôi muốn tự cài đặt thì sao?

Skill cũng đưa ra các lệnh cài đặt thủ công như một lựa chọn thay thế.

Chi tiết

Mô tả gốc của tác giả

Use when setting up Playwright in a project ('set up playwright', 'add e2e tests', 'configure playwright', 'init playwright').

repo: alirezarezvani/claude-skills

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9477
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự