Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

playwright-testing

БесплатноБез исполняемых скриптовНе проверен

Use for any question or task about Playwright tests, including quick how-to questions, one login or form test, and one flaky pasted test: role-based locators…

testlandот testland★ 18 звёзд на GitHub

Об этом скилле

playwright-testing

Overview

Per pw-intro:

"Playwright Test is an end-to-end test framework for modern web apps. It bundles test runner, assertions, isolation, parallelization and rich tooling."

"The framework supports Chromium, WebKit, and Firefox across Windows, Linux, and macOS." (pw-intro)

When to use

  • New web E2E project; pick Playwright as the modern default.
  • Cross-browser coverage matters (see references/browser-matrix.md) - Playwright's three-engine support is the differentiator.
  • Migration from Selenium / WebDriver-based stacks (see selenium-testing).

Step 1 - Scaffold

Per pw-intro:

npm init playwright@latest

The init prompts choose TypeScript/JavaScript, tests folder, GitHub Actions CI, and browser binaries.

What lands: playwright.config.ts + tests/example.spec.ts + package.json updates.

Step 2 - Author tests with accessibility-first locators

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

test('checkout flow happy path', async ({ page }) => {
  await page.goto('/');

  await page.getByRole('link', { name: /sign in/i }).click();
  await page.getByLabel('Email').fill('[email protected]');
  await page.getByLabel('Password').fill('test-password');
  await page.getByRole('button', { name: /sign in/i }).click();

  await expect(page.getByRole('heading', { name: /welcome/i })).toBeVisible();

  await page.getByRole('link', { name: /shop/i }).click();
  await page.getByRole('link', { name: /BOOK-001/i }).click();
  await page.getByRole('button', { name: /add to cart/i }).click();
  await expect(page.getByTestId('cart-count')).toHaveText('1');
});

Prefer getByRole / getByLabelText / getByText over CSS class / XPath. Web-first assertions (await expect(...)) auto-wait within the test timeout.

Step 3 - Page Object pattern

// tests/page-objects/CheckoutPage.ts
import { Page, expect } from '@playwright/test';

export class CheckoutPage {
  constructor(private page: Page) {}

  async signIn(email: string, password: string) {
    await this.page.getByLabel('Email').fill(email);
    await this.page.getByLabel('Password').fill(password);
    await this.page.getByRole('button', { name: /sign in/i }).click();
  }

  async addToCart(sku: string) {
    await this.page.getByRole('link', { name: new RegExp(sku, 'i') }).click();
    await this.page.getByRole('button', { name: /add to cart/i }).click();
  }

  async expectConfirmation() {
    await expect(this.page.getByRole('heading', { name: /order confirmed/i })).toBeVisible();
  }
}

Tests import the Page Object:

test('checkout', async ({ page }) => {
  const checkout = new CheckoutPage(page);
  await checkout.signIn('[email protected]', 'pwd');
  await checkout.addToCart('BOOK-001');
  await checkout.expectConfirmation();
});

Step 4 - Configuration

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

export default defineConfig({
  testDir: './tests',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 4 : undefined,
  reporter: [
    ['html'],
    ['junit', { outputFile: 'reports/junit.xml' }],
  ],
  use: {
    baseURL: process.env.BASE_URL || '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'] } },
  ],
});

trace: 'on-first-retry' captures rich debug info (DOM snapshots, network, console) only when needed - avoids storage cost on passing runs.

The same devices catalog covers mobile-web emulation: add projects spreading devices['iPhone 15'] / devices['Pixel 7'] for mobile-breakpoint regression (viewport, DPR, user agent, .tap() touch synthesis, per-device snapshots, CI matrix) - see references/mobile-emulation.md. For the full cross-browser matrix - branded chrome / msedge channel projects, the per-browser CI matrix with fail-fast: false, and the engine-vs-channel decision table - see references/browser-matrix.md.

Step 5 - Run

Per pw-intro:

# All tests, all browsers, headless, parallel
npx playwright test

# Specific browser
npx playwright test --project=chromium

# Headed (see the browser)
npx playwright test --headed

# UI Mode (watch + debug)
npx playwright test --ui

# Single test file
npx playwright test tests/checkout.spec.ts

# Single test by name
npx playwright test -g "checkout flow"

Step 6 - Trace viewer

When a test fails, the trace contains everything needed to debug:

# After a failure
npx playwright show-trace test-results/<...>/trace.zip

The

Полный SKILL.md на GitHub

Установить playwright-testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.tessl-plugin/plugin.jsonevals/background-job-polled-with-a-loop/criteria.jsonevals/background-job-polled-with-a-loop/task.mdevals/ci-config-and-sharding/criteria.jsonevals/ci-config-and-sharding/task.mdevals/dashboard-image-check-always-red/criteria.jsonevals/dashboard-image-check-always-red/task.mdevals/flaky-checkout-spec/criteria.jsonevals/flaky-checkout-spec/task.mdevals/iphone-tickets-closed-as-cannot-reproduce/criteria.jsonevals/iphone-tickets-closed-as-cannot-reproduce/task.mdevals/login-repeated-in-every-test/criteria.jsonevals/login-repeated-in-every-test/task.mdevals/mobile-breakpoint-projects/criteria.jsonevals/mobile-breakpoint-projects/task.mdevals/partner-api-rate-limits-the-suite/criteria.jsonevals/partner-api-rate-limits-the-suite/task.mdevals/second-window-and-download-steps-hang/criteria.jsonevals/second-window-and-download-steps-hang/task.mdevals/strict-mode-two-elements-match/criteria.jsonevals/strict-mode-two-elements-match/task.mdreferences/browser-matrix.mdreferences/mobile-emulation.md

FAQ

Что делает скилл playwright-testing?

Use for any question or task about Playwright tests, including quick how-to questions, one login or form test, and one flaky pasted test: role-based locators, web-first assertions instead of waitForTimeout, page objects, config and browser projects, traces, sharding a slow suite in CI. Has the anti-pattern table for flaky Playwright tests.

Как установить скилл playwright-testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл playwright-testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить playwright-testing с