jpskill.com
🛠️ 開発・MCP コミュニティ

create-regression-test

Playwright E2Eテストスイート向けに、リグレッションテストやスモークテストの仕様ファイル、テストデータJSON、フィクスチャ更新を自動生成し、テストの骨組みを効率的に構築するSkill。

📜 元の英語説明(参考)

Creates a regression or smoke test spec file for a Playwright E2E test suite. Generates the spec file, test data JSON, and fixture updates. Handles complete test scaffolding including beforeAll cleanup, POM usage, and parallel-safe data. Use when asked to write a regression test, smoke test, or E2E test for a feature.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Playwright E2Eテストスイート向けに、リグレッションテストやスモークテストの仕様ファイル、テストデータJSON、フィクスチャ更新を自動生成し、テストの骨組みを効率的に構築するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o create-regression-test.zip https://jpskill.com/download/10197.zip && unzip -o create-regression-test.zip && rm create-regression-test.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10197.zip -OutFile "$d\create-regression-test.zip"; Expand-Archive "$d\create-regression-test.zip" -DestinationPath $d -Force; ri "$d\create-regression-test.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して create-regression-test.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → create-regression-test フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

回帰/スモークテストの作成

関連するテストデータとフィクスチャの統合を含む、完全なテスト仕様を生成します。


ワークフロー

  1. ユーザーの要求から機能名 (feature name) を決定します。
  2. スイート (suite) を決定します — 回帰 (regression) (デフォルト) またはスモーク (smoke)。
  3. e2e/poms/{feature}.page.tsPOM が存在するか確認します。
    • 存在する場合、その公開メソッドと JSDoc を読み、利用可能なアクションを理解します。
    • 存在しない場合、最初に create-pom スキルを使用して作成します。
  4. e2e/test-data/{feature}.jsonテストデータが存在するか確認します。
    • 存在する場合、既存のデータ構造を読み込んで使用します。
    • 存在しない場合、テンプレートデータを含む JSON ファイルを作成します。
  5. e2e/fixtures/base.tsフィクスチャを確認します。
    • 機能 (feature) がまだ登録されていない場合は、インターフェースとローダーを追加します。
  6. 適切なディレクトリに スペックファイルを作成します。
  7. テストを実行して、合格することを確認します。
    npx playwright test --project="chromium:regression" {feature}.spec.ts

スペックファイルの構造

すべてのスペックは、この正確なパターンに従います。

import { test } from '../../fixtures/base';
import { getAuthFilePath } from '../../helpers/env-config';
import { FeaturePage } from '../../poms/feature.page';

const authFile = getAuthFilePath();

test.describe('Feature Name Tests', () => {
    // One-time setup: clean stale data from previous failed runs
    test.beforeAll(async ({ browser }) => {
        const context = await browser.newContext({
            storageState: authFile,
        });
        const page = await context.newPage();
        const pom = new FeaturePage(page);
        await pom.setUp();
        await page.close();
        await context.close();
    });

    test('should create a new item', async ({ page, testData }) => {
        const pom = new FeaturePage(page);
        const item = testData.feature.items[0];

        await pom.navigateToPage();
        await pom.createItem(item.name, item.value);
        await pom.verifyItemExists(item.name);
    });

    test('should edit an existing item', async ({ page, testData }) => {
        const pom = new FeaturePage(page);
        const item = testData.feature.items[0];
        const updated = testData.feature.updatedItem;

        await pom.navigateToPage();
        await pom.createItem(item.name, item.value);
        await pom.editItem(item.name, updated.name, updated.value);
        await pom.verifyItemExists(updated.name);
    });

    test('should delete an item', async ({ page, testData }) => {
        const pom = new FeaturePage(page);
        const item = testData.feature.items[1];

        await pom.navigateToPage();
        await pom.createItem(item.name, item.value);
        await pom.deleteItem(item.name);
        await pom.verifyItemNotExists(item.name);
    });
});

重要なルール

スペックでの生のページ呼び出しの禁止

スペックは、page.getByRole()page.locator()page.waitForTimeout()、または生の Playwright ページメソッドを呼び出してはなりません。すべてのインタラクションは POM を介して行われます。

スペックで page を使用できるのは、以下の用途のみです。

  1. POM コンストラクタに渡す: new FeaturePage(page)
  2. beforeAll でコンテキストを作成する: browser.newContext() / context.newPage()

テストの独立性

  • すべてのテストは、pom.navigateToPage() を介して個別にナビゲートします。
  • すべてのテストは、独自のデータを作成します — 他のテストからのデータに依存しないでください。
  • テストは並行して実行されます — 衝突を避けるために、一意のサフィックスが付いたテストデータを使用します。

カスタムテストのインポート

常にプロジェクトのカスタムフィクスチャから test をインポートします。

// 正しい
import { test } from '../../fixtures/base';

// 間違い — testData フィクスチャへのアクセスを失う
import { test } from '@playwright/test';

テストデータ

JSON ファイル: e2e/test-data/{feature}.json

{
    "items": [
        { "name": "ItemA", "key": "keyA", "value": "some-value" },
        { "name": "ItemB", "key": "keyB", "value": "other-value" }
    ],
    "updatedItem": { "name": "Updated", "value": "new-value" }
}

ルール

  • スペックファイルまたは POM ファイルにデータをハードコードしないでください
  • すべての文字列値には、testData フィクスチャを介して一意のサフィックスが自動的に付加されます。
  • POM メソッドがパラメータとして期待するものと一致するようにデータを整形します。

完全なテンプレートについては、references/spec-template.md および references/test-data-template.md を参照してください。


beforeAll クリーンアップパターン

beforeAll ブロックは以下を実行する必要があります。

  1. 新しいブラウザコンテキストを手動で作成します (テストのページフィクスチャからではなく)。
  2. 認証のために storageState をロードします。
  3. POM をインスタンス化し、setUp() を呼び出します。
  4. 完了したら、ページとコンテキストを閉じます。

これにより、以前の失敗した実行からの古いデータが、テストの実行前に確実にクリーンアップされます。


ファイルチェックリスト

回帰/スモークテストを作成するときは、以下を生成する必要があります。

  • [ ] e2e/poms/{feature}.page.ts — POM (作成または更新)
  • [ ] e2e/test-data/{feature}.json — テストデータ
  • [ ] e2e/fixtures/base.ts — 機能インターフェースとローダーで更新 (新しい機能の場合)
  • [ ] e2e/tests/regression/{feature}.spec.ts (または tests/smoke/) — スペックファイル
  • [ ] すべてのテストは独立しており、並列実行に対応しています。
  • [ ] スペックに生の page 呼び出しはありません。
  • [ ] ハードコードされたテストデータはありません。
  • [ ] テストは chromium で合格します: npx playwright test --project="chromium:regression" {feature}.spec.ts
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Create Regression / Smoke Test

Generate a complete test spec with associated test data and fixture integration.


Workflow

  1. Determine the feature name from the user's request
  2. Determine the suite — regression (default) or smoke
  3. Check if a POM exists in e2e/poms/{feature}.page.ts
    • If yes, read its public methods and JSDoc to understand available actions
    • If no, create one first using the create-pom skill
  4. Check if test data exists in e2e/test-data/{feature}.json
    • If yes, read and use the existing data shape
    • If no, create the JSON file with template data
  5. Check fixtures in e2e/fixtures/base.ts
    • If the feature is not yet registered, add the interface and loader
  6. Create the spec file in the appropriate directory
  7. Run the test to verify it passes:
    npx playwright test --project="chromium:regression" {feature}.spec.ts

Spec File Structure

Every spec follows this exact pattern:

import { test } from '../../fixtures/base';
import { getAuthFilePath } from '../../helpers/env-config';
import { FeaturePage } from '../../poms/feature.page';

const authFile = getAuthFilePath();

test.describe('Feature Name Tests', () => {
    // One-time setup: clean stale data from previous failed runs
    test.beforeAll(async ({ browser }) => {
        const context = await browser.newContext({
            storageState: authFile,
        });
        const page = await context.newPage();
        const pom = new FeaturePage(page);
        await pom.setUp();
        await page.close();
        await context.close();
    });

    test('should create a new item', async ({ page, testData }) => {
        const pom = new FeaturePage(page);
        const item = testData.feature.items[0];

        await pom.navigateToPage();
        await pom.createItem(item.name, item.value);
        await pom.verifyItemExists(item.name);
    });

    test('should edit an existing item', async ({ page, testData }) => {
        const pom = new FeaturePage(page);
        const item = testData.feature.items[0];
        const updated = testData.feature.updatedItem;

        await pom.navigateToPage();
        await pom.createItem(item.name, item.value);
        await pom.editItem(item.name, updated.name, updated.value);
        await pom.verifyItemExists(updated.name);
    });

    test('should delete an item', async ({ page, testData }) => {
        const pom = new FeaturePage(page);
        const item = testData.feature.items[1];

        await pom.navigateToPage();
        await pom.createItem(item.name, item.value);
        await pom.deleteItem(item.name);
        await pom.verifyItemNotExists(item.name);
    });
});

Critical Rules

No Raw Page Calls in Specs

A spec must NEVER call page.getByRole(), page.locator(), page.waitForTimeout(), or any raw Playwright page method. All interaction goes through the POM.

Only acceptable uses of page in a spec:

  1. Passing it to the POM constructor: new FeaturePage(page)
  2. Creating contexts in beforeAll: browser.newContext() / context.newPage()

Test Independence

  • Every test navigates independently via pom.navigateToPage()
  • Every test creates its own data — never rely on data from another test
  • Tests run in parallel — use unique-suffixed test data to avoid collisions

Custom Test Import

Always import test from the project's custom fixtures:

// CORRECT
import { test } from '../../fixtures/base';

// WRONG — loses access to testData fixture
import { test } from '@playwright/test';

Test Data

JSON File: e2e/test-data/{feature}.json

{
    "items": [
        { "name": "ItemA", "key": "keyA", "value": "some-value" },
        { "name": "ItemB", "key": "keyB", "value": "other-value" }
    ],
    "updatedItem": { "name": "Updated", "value": "new-value" }
}

Rules

  • Never hardcode data in spec or POM files
  • All string values get unique suffixes automatically via the testData fixture
  • Shape the data to match what the POM methods expect as parameters

See references/spec-template.md and references/test-data-template.md for full templates.


beforeAll Cleanup Pattern

The beforeAll block must:

  1. Create a new browser context manually (not from the test's page fixture)
  2. Load storageState for authentication
  3. Instantiate the POM and call setUp()
  4. Close the page and context when done

This ensures stale data from previous failed runs is cleaned before any test executes.


File Checklist

When creating a regression/smoke test, you should produce:

  • [ ] e2e/poms/{feature}.page.ts — POM (create or update)
  • [ ] e2e/test-data/{feature}.json — Test data
  • [ ] e2e/fixtures/base.ts — Updated with feature interface and loader (if new feature)
  • [ ] e2e/tests/regression/{feature}.spec.ts (or tests/smoke/) — Spec file
  • [ ] All tests are independent and parallel-safe
  • [ ] No raw page calls in the spec
  • [ ] No hardcoded test data
  • [ ] Tests pass on chromium: npx playwright test --project="chromium:regression" {feature}.spec.ts