オプション

Playwrightのテストを生成します。ユーザーが「テストを作成する」、「テストを生成する」、「〜のテストを追加する」、「このコンポーネントをテストする」、「e2eテスト」、 「~のテストを作成」、 「このページをテスト」、または「この機能をテスト」と言った場合に使用します。

...すべて拡張します
10
更新された時間 2026年8月25日

generateについて

このスキル「generate」は、ユーザーストーリー、URL、コンポーネントパス、または機能の説明から、本番環境対応のPlaywrightエンドツーエンドテストを生成します。 このスキルは、信頼性が高く、規約に準拠したブラウザテストを手作業で記述するという課題を解決します。何かを生成する前に、既存のプロジェクトを調査してテストディレクトリ、ベースURL、フィクスチャ、およびページオブジェクトの規約を学習するため、出力結果は汎用的なテンプレートではなく、対象のコードベースに適合したものになります。

このワークフローでは、テスト対象を解析し、「Explore」サブエージェントを使用してPlaywrightの設定や既存のテストを読み取り、適切なテンプレート(認証、CRUD、チェックアウト、検索、フォーム、ダッシュボード、設定、オンボーディング、API、アクセシビリティ)を選択し、実際のセレクタやデータを用いて適応させます。Generate dのテストは、厳格な品質ルールに従っています。具体的には、単純なCSSよりもgetByRole、getByLabel、その他のセマンティックロケーターを優先するロケーターの優先順位、Webファーストの自動再試行アサーション、そしてwaitForTimeout、page.$セレクタ、不要なpage.evaluateといったアンチパターンの明示的な禁止です。 また、TypeScriptとJavaScriptの扱い、ページオブジェクト、フィクスチャに関するプロジェクトの規約に準拠しており、必要に応じてページオブジェクト、フィクスチャ、テストデータファイルをサポートするgenerateを使用できます。最後に、Playwright CLIを使用してgeneratedテストを実行し、失敗した箇所を反復処理します。

これは、Playwrightを使用し、自身のプロジェクトのスタイルに合わせて一貫性があり、保守性の高いエンドツーエンド(e2e)テストカバレッジgenerateを実現したいWeb開発者やQAエンジニアを対象としています。 ユースケースには、ログインやチェックアウトのフロー、フォームの検証、検索・フィルタリングのUI、およびコンポーネントの動作のテストなどが含まれます。このスキルには、認証、CRUD、検証フローに関する具体的なテスト例のライブラリである SKILL.md および patterns.md が付属しています。

よくある質問

どのような入力を受け付けますか?

ユーザーストーリー、コンポーネントファイルのパス、ページまたは URL、あるいは機能名(例:「ユーザーはメールアドレスとパスワードでログインできる」や「src/components/UserProfile.tsx」など)を受け付けます。

どのようなロケーターおよびアサーションスタイルを強制しますか?

セマンティックロケーター(getByRole、getByLabel、getByText、getByPlaceholder、getByTestIdの順)を優先し、手動によるテキスト抽出の代わりに、常にWebファーストの自動再試行アサーションを使用します。

どのようなアンチパターンを回避していますか?

page.waitForTimeout()、page.$/page.$$ セレクタ、やむを得ない場合を除く裸の CSS セレクタ、およびロケーターで処理可能な事柄に対する page.evaluate() は決して使用しません。

作成したテストは検証されますか?

はい。`npx playwright test --reporter=list` コマンドで generated テストを実行し、エラーがあればそれを読み取り、アプリではなくテストを修正することで、アプリ本体の問題を正確に報告します。

自分のプロジェクトの規約に適合しますか?

playwright.config.ts および既存のテストを読み取り、TypeScript 対 JavaScript の設定、既存のページオブジェクト、カスタムフィクスチャ、test-data ディレクトリに合わせて調整します。

すべてのファイル

2 ファイル SKILL.md 4.4 KB Viewpatterns.md 5.7 KB View
GitHubで見る

Generate production-ready Playwright tests from a user story, URL, component name, or feature description.

Input

$ARGUMENTS contains what to test. Examples:

  • "user can log in with email and password"
  • "the checkout flow"
  • "src/components/UserProfile.tsx"
  • "the search page with filters"

Steps

1. Understand the Target

Parse $ARGUMENTS to determine:

  • User story: Extract the behavior to verify
  • Component path: Read the component source code
  • Page/URL: Identify the route and its elements
  • Feature name: Map to relevant app areas

2. Explore the Codebase

Use the Explore subagent to gather context:

  • Read playwright.config.ts for testDir, baseURL, projects
  • Check existing tests in testDir for patterns, fixtures, and conventions
  • If a component path is given, read the component to understand its props, states, and interactions
  • Check for existing page objects in pages/
  • Check for existing fixtures in fixtures/
  • Check for auth setup (auth.setup.ts or storageState config)

3. Select Templates

Check templates/ in this plugin for matching patterns:

If testing...Load template from
Login/auth flow../pw/templates/auth/login.md
CRUD operationstemplates/crud/
Checkout/paymenttemplates/checkout/
Search/filter UItemplates/search/
Form submissiontemplates/forms/
Dashboard/datatemplates/dashboard/
Settings pagetemplates/settings/
Onboarding flowtemplates/onboarding/
API endpointstemplates/api/
Accessibilitytemplates/accessibility/

Adapt the template to the specific app — replace {{placeholders}} with actual selectors, URLs, and data.

4. Generate the Test

Follow these rules:

Structure:

import { test, expect } from '@playwright/test';// Import custom fixtures if the project uses themtest.describe('Feature Name', () => {  // Group related behaviors  test('should <expected behavior>', async ({ page }) => {    // Arrange: navigate, set up state    // Act: perform user action    // Assert: verify outcome  });});

Locator priority (use the first that works):

  1. getByRole() — buttons, links, headings, form elements
  2. getByLabel() — form fields with labels
  3. getByText() — non-interactive text content
  4. getByPlaceholder() — inputs with placeholder text
  5. getByTestId() — when semantic options aren't available

Assertions — always web-first:

// GOOD — auto-retriesawait expect(page.getByRole('heading')).toBeVisible();await expect(page.getByRole('alert')).toHaveText('Success');// BAD — no retryconst text = await page.textContent('.msg');expect(text).toBe('Success');

Never use:

  • page.waitForTimeout()
  • page.$(selector) or page.$$(selector)
  • Bare CSS selectors unless absolutely necessary
  • page.evaluate() for things locators can do

Always include:

  • Descriptive test names that explain the behavior
  • Error/edge case tests alongside happy path
  • Proper await on every Playwright call
  • baseURL-relative navigation (page.goto('/') not page.goto('http://...'))

5. Match Project Conventions

  • If project uses TypeScript → generate .spec.ts
  • If project uses JavaScript → generate .spec.js with require() imports
  • If project has page objects → use them instead of inline locators
  • If project has custom fixtures → import and use them
  • If project has a test data directory → create test data files there

6. Generate Supporting Files (If Needed)

  • Page object: If the test touches 5+ unique locators on one page, create a page object
  • Fixture: If the test needs shared setup (auth, data), create or extend a fixture
  • Test data: If the test uses structured data, create a JSON file in test-data/

7. Verify

Run the generated test:

npx playwright test <generated-file> --reporter=list

If it fails:

  1. Read the error
  2. Fix the test (not the app)
  3. Run again
  4. If it's an app issue, report it to the user

Output

  • Generated test file(s) with path
  • Any supporting files created (page objects, fixtures, data)
  • Test run result
  • Coverage note: what behaviors are now tested

すべてのファイル

2件のファイル

generateをインストール

スキルファイルをダウンロードし、.claude/skills/ ディレクトリに解凍してください。

ZIPをダウンロード

リポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。

git clone https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/playwright-pro/skills/generate/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

コピー コピー
クイックセットアップ: スキルフォルダを .claude/skills/ にコピーしてください。Claude が自動的にスキルを検出して使用します。

関連スキル

playwright-cli
更新された時間 2026年6月29日
frontend-testing-best-practices
更新された時間 2026年7月7日
Playwright Browser Automation
更新された時間 2026年6月29日
playwright-generate-test
更新された時間 2026年6月29日
OR