write-playwright-e2e-code
Playwright E2E テストコードを生成。test.step で日本語ステップ名を使用し、コメント禁止。E2E テスト作成・Playwright コード生成時に使用。
Install
mkdir -p .claude/skills/write-playwright-e2e-code && curl -L -o skill.zip "https://mcp.directory/api/skills/download/1899" && unzip -o skill.zip -d .claude/skills/write-playwright-e2e-code && rm skill.zipInstalls to .claude/skills/write-playwright-e2e-code
About this skill
Playwright E2E テスト
test.step 区切り
- 論理的な区切りは
test.step("日本語", async () => { ... })で表現 - 適切な粒度: ユーザー操作単位・UI 状態確認単位で区切る。入れ子も可
- expect は step 内に含める
- 既に step に分かれている関数は step の外で呼び出す
Good:
await navigateToMain(page);
await test.step("ダウンロードモーダルを表示する", async () => {
await page.getByRole("button", { name: "ダウンロード" }).click();
await expect(page.getByRole("dialog")).toBeVisible();
});
await test.step("モーダルを閉じると消える", async () => {
await page.getByRole("button", { name: "閉じる" }).click();
await expect(page.getByRole("dialog")).toBeHidden();
});
step 名
- 「何をするか」「どうあるべきか」が分かる表現にする
- 詳細な説明文にはせず、フローの節目を表す短い動詞句にする
- 「~を確認する」など冗長な表現は避ける
- 体言止めは使わない
Good:
await test.step("ダウンロードモーダルを表示する", async () => {});
Bad 1 (step 名が体言止め):
await test.step("ダウンロードモーダルを表示", async () => {});
Bad 2 (step 名が冗長):
await test.step("ダウンロードボタンをクリックしてモーダルが表示されることを確認する", async () => {});
Bad 3 (step 名に「~を確認する」を含む):
await test.step("モーダルを閉じると消えることを確認する", async () => {});
コメント
- What を説明するコメントは削除: step 名で表現する
- Why(目的・意図・理由)を説明するコメントは残す: なぜその待機時間が必要か、なぜその順序で実行するか等
Good (意図を説明):
await page.waitForTimeout(5000); // エンジン読み込みを待機
locator・変数の共有
locator の宣言場所は使用範囲で決める:
- 複数 step で使う: test 関数直下で宣言
- 1 つの step でのみ使う: その step 内で宣言(外に出さない)
Good:
test("テスト名", async ({ page }) => {
const input = page.getByLabel("入力欄");
await test.step("入力する", async () => {
await input.fill("テスト");
});
await test.step("入力値が反映される", async () => {
await expect(input).toHaveValue("テスト");
});
});
Bad 1 (不要な外部宣言):
test("テスト名", async ({ page }) => {
const accentPhrase = page.locator(".accent-phrase");
await test.step("検証する", async () => {
await expect(accentPhrase).toBeVisible();
});
});
Bad 2 (重複宣言):
test("テスト名", async ({ page }) => {
await test.step("入力する", async () => {
const input = page.getByLabel("入力欄");
await input.fill("テスト");
});
await test.step("検証する", async () => {
const input = page.getByLabel("入力欄");
await expect(input).toHaveValue("テスト");
});
});
step 間の値の受け渡し
- 再代入しない: step から return して const で受け取る
- 再代入する: let で宣言して step 内で代入
Good 1:
const before = await test.step("初期値を取得する", async () => {
return await getValue(page);
});
await test.step("値が変化している", async () => {
expect(await getValue(page)).not.toEqual(before);
});
Bad 1 (再代入しないのに let で宣言):
let before: number;
await test.step("初期値を取得する", async () => {
before = await getValue(page);
});
await test.step("値が変化している", async () => {
expect(await getValue(page)).not.toEqual(before);
});
Good 2 (再代入する場合は let でも OK):
let count: number;
await test.step("1回目の操作をする", async () => {
await page.getByRole("button").click();
count = await getCount(page);
expect(count).toBe(1);
});
await test.step("2回目の操作をする", async () => {
await page.getByRole("button").click();
count = await getCount(page);
expect(count).toBe(2);
});
ロジックの共通化
| スコープ | 方法 |
|---|---|
| test 内のみ | test 関数内で変数やローカル関数を定義 |
| ファイル内の複数 test | ファイルスコープでローカル関数を定義 |
| 複数ファイル | 共通ファイルにエクスポート関数を追加 |
既存コードとの整合
既存ファイル・関数名の指定がある場合はそれを優先。ない場合は既存 E2E の命名・スタイルに合わせる。
You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.