Playwright-based E2E testing for SvelteKit, covering UI components and async network events.

Install

mkdir -p .claude/skills/e2etest && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/12336" && unzip -o skill.zip -d .claude/skills/e2etest && rm skill.zip

Installs to .claude/skills/e2etest

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

GLATasks の e2e テスト(Playwright)実装リファレンス。 `app/tests/` 配下のテストファイルを編集するとき、または SvelteKit の hydration パターン・ ダイアログ操作・マルチブラウザ同期テスト・SSE 制御を扱うときに呼び出す。
141 charsno explicit “when” trigger
Intermediate

Key capabilities

  • →Write Playwright tests for SvelteKit applications
  • →Handle multi-browser and multi-tab testing scenarios
  • →Control Server-Sent Events (SSE) and network requests
  • →Interact with custom dialog components
  • →Test clipboard operations

How it works

The skill provides patterns and guidelines for writing Playwright tests, including handling SvelteKit hydration, dialog interactions, and network control. It uses `data-testid` attributes for selectors.

Inputs & outputs

You give it
SvelteKit application and test files in `app/tests/`
You get back
Playwright e2e test scripts and execution results

When to use e2etest

  • →Write E2E tests for UI components
  • →Simulate network conditions
  • →Test multi-user synchronization

About this skill

e2eテスト (Playwright)

基本方針

  • テストファイルはapp/tests/に配置する
  • セレクタはdata-testid属性を使用する(CSSクラスに依存しない)
  • テストデータはbeforeAll / afterAllで作成・削除し、 共通ヘルパーでテスト用の名前を一意にする
  • ローカルのmake test-e2eもCIも空のDBから始まる。リストの選択や利用者設定など試験が前提とする状態は試験自身で用意し、 開発用DBに残ったデータへ依存させない(ローカルは別のComposeプロジェクトを毎回空の試験用DBで起動する。Makefileのtest-e2eを参照)

失敗時の診断成果物の保持

E2Eの失敗を観測した場合は、原因調査や再実行に入る前に初回の診断成果物(trace・スクリーンショット・error-context.md・動画)を別の場所へ複製する。 Playwrightは実行の開始時に出力先(outputDir)を削除するため、同じ出力先で次の実行を始めると初回の資料が消える。 観測記録はdocs/development/audit-records.mdの「.claude/skills/e2etest/SKILL.md:失敗時の診断成果物の保持:2026年10月3日」にある。 成功した実行では保持の操作は要らない。

  1. 実際の出力先を特定する。E2E_OUTPUT_DIRを指定した実行ではその指定先、未指定ならtest-resultsとする
  2. 自分のmanaged-tempの中に、その実行のための未使用の保存先を決める。出力先の外に置き、実行ごとに別の場所とする
  3. cp -a -- <出力先> <保存先>で複製し、終了コード0を確認する
  4. 失敗ログが示した資料のパスが保存先にも存在することを確認する
  5. 確認を終えてから原因調査と再実行へ進む。再実行の成否にかかわらず、初回の失敗の調査には保存先の資料を使う

基本パターン

SvelteKitのhydration完了を待つには、次のtRPCレスポンス待ちパターンを使う。

waitForSelectorはSSRで描画されるため即返るが、onMountのAPI呼び出しはまだ完了していない。 SSE接続が常時開いているためwaitUntil: "networkidle"は利用できない。

await Promise.all([
  page.goto("/"),
  page.waitForResponse((res) => res.url().includes("/api/trpc")),
]);

セレクタの曖昧さに注意する。 button:has-text("追加")はサイドバーのリスト追加ボタンにも一致するため、 main button:has-text("追加")のようにスコープを限定する。

複数ブラウザ・マルチタブ

Playwright Testのbrowser.newContext()では、呼び出しで指定しなかったキーへplaywright.config.tsのuse(storageState・baseURL・ignoreHTTPSErrorsを含む)が既定値として入る。 このため、オプションを省略したコンテキストは共通テストユーザーでログイン済みになる。 未ログインのコンテキストや、テスト内で新しいユーザーを登録するコンテキストではstorageState: { cookies: [], origins: [] }を明示する。 省略すると/auth/regist_userなどの認証画面がトップページへリダイレクトされる。 認証状態を変える場合も、共通のコンテキストオプションを基に必要な項目だけ上書きする。

複数ブラウザ(多端末同期)のテスト:

import { makeContextOptions } from "./helpers/common.ts";

const ctx = await browser.newContext(makeContextOptions());

上記ctxを2つ生成し、終了時はfinallyでctx.close()する。

SSE・ネットワーク制御

SSEイベントを受信しない状態を再現する場合は、 await ctx.route("**/api/events", route => route.abort())でSSEエンドポイントへの接続だけを遮断する。 /api/trpcは通るので削除等の通常操作は引き続き実行できる。

UI操作

ページ全体のスクロールを内部スクロールへ変更する場合など、高さ制約を変える作業では次をテスト設計時に確認する。

  • 可変高の子要素を列挙し、各要素の公開上限と複数要素が同時に上限へ達する組合せを検証する
  • 高さ制約の領域に隣接する主要操作が表示され、操作できることを検証する

ダイアログ操作の規約

確認・入力ダイアログはConfirmDialogとPromptDialogを使い、共通のDialogがHTMLのdialog要素を開く。 ネイティブのwindow.confirm / window.promptは発火しない。 そのため、e2eテストではPlaywrightのdialogイベント経由(page.once("dialog", ...))ではなく、 ダイアログ内のボタンを直接押下する。

  • 確認(削除等)はgetByRole("dialog")スコープの削除ボタンを押す
  • 入力(名前変更等)はgetByRole("dialog")スコープのinput[type="text"]にfillしてから、 同スコープのbutton:has-text("変更")をclickして確定する

ネスト時に外側ダイアログのボタンを誤選択しないよう、アクセシブル名を含むgetByRole("dialog")でlocatorを構築する。 複数候補がある場合は.last()で最前面のダイアログを取り出す。 TabとShift+Tabの循環、閉じた後のフォーカス復帰、Escapeで最前面だけが閉じることを実ブラウザーで検証する。 固定のwaitForTimeoutではなく、操作成功の応答と画面状態を待つ。

クリップボード操作

クリップボードを使うテストでは、操作前に権限を付与してからnavigator.clipboard.readText()で検証する。

await page.context().grantPermissions(["clipboard-read", "clipboard-write"]);
await taskRow.locator('[data-testid="task-copy-btn"]').dispatchEvent("click");
await taskRow
  .locator('[data-testid="task-copy-menu"]')
  .waitFor({ timeout: 15000 });
await taskRow.locator('[data-testid="task-copy-all"]').dispatchEvent("click");
const copied = await page.evaluate(() => navigator.clipboard.readText());
expect(copied).toBe(`${title}\n\n${notes}`);

モバイルテスト

playwright.config.tsのmobile-chromeプロジェクトはモバイルブレークポイントの回帰検知用。 viewportのみPixel 5サイズへoverrideする構成を採用している(完全なmobile emulationではない)。 実タッチ入力でのD&D動作確認はChrome DevToolsのデバイスエミュレーション等で手動検証する。

高さ制約の回帰テストを追加または変更する前に、playwright.config.tsのtestMatchとtestIgnoreを読み、 対象ファイルがデスクトップとモバイルのどちらで実行されるかを確認する。 高さ制約の領域と隣接する主要操作への到達性は、デスクトップと該当するモバイルテストの双方で検証する。

状態依存テストのリセット

ユーザー設定(users.preferences等のサーバー側状態)に依存するテストは、 前回テスト失敗時の状態が残ると正しく動作しない。 本題の検証に入る前に冒頭で必ず初期状態へリセットしてから進める。 afterEachでのリセットだけではテスト失敗時に巻き戻らないため、冒頭での明示的リセットを優先する。

共通ヘルパーの利用

e2eテストでは共通ヘルパー(app/tests/helpers/common.ts)を利用する。 各テストファイルでBASE_URLやstorageStateパスを再定義しない。

公開シンボル一覧:

  • BASE_URLはテスト対象のベースURL(環境変数BASE_URL優先、指定が無ければhttps://localhost:38180)
  • makeContextOptions(overrides?)は認証状態、接続先、HTTPSと画面サイズの共通オプションを返す
  • uniqueTestName(prefix)はテスト用の名前を一意にする
  • requireBoundingBox(locator)は要素の位置と寸法を取得し、取得できなければ失敗する
  • createListFromPage(page, listName, select = true)は画面からリストを作成し、必要に応じて選択する
  • addTask(page, text, { todo?, openEdit? })はタスクを追加し、その行のLocatorを返す
  • isTrpcUrl(url, procedure)は指定手続きへのtRPC通信か判定する
  • STORAGE_STATE_PATHは認証状態ファイルの絶対パス(import.meta.dirname基準)
  • isMutationResponse(response, procedure)は指定したprocedureを含むtRPC応答かどうかを判定する
  • waitForMutationResponse(page, procedure)は操作前に登録し、指定procedureのmutation応答を待つ
  • waitForSuccessfulMutationResponse(page, procedure)は指定procedureのmutationがHTTP成功で完了するまで待つ
  • waitForTaskUpdateResponse(page)はタスク更新mutationの応答を待つ
  • waitForPersistedTask(taskRow)は楽観追加されたタスクが実IDへ置き換わるまで待つ
  • toggleTaskAndWaitForUpdate(page, checkbox)はタスク状態を1段階進め、成功応答と画面状態の反映後に返る
  • setupTestList(browser, listName)はbeforeAllからテスト用リストを作成する
  • setupTestLists(browser, listNames)は1つのブラウザーコンテキストで複数のテスト用リストを作成する
  • cleanupTestList(browser, listName)はafterAllからテスト用リストを削除する
  • cleanupTestLists(browser, listNames)は1つのブラウザーコンテキストで複数のテスト用リストを削除する

テスト用リストの作成・削除は公開UI(サイドバーのリスト追加と削除ダイアログ)を操作する。 開発サーバーだけに存在するViteのソースモジュールへは依存させない。

開発サーバーとCIで同じ仕組みを観測に使う

ローカルのmake test-e2eは開発サーバー、CIはproductionビルドを対象にする。 テストデータの作成・削除と、試験が観測のきっかけにする仕組み(バナーの表示、通知、状態の変化など)は、両方の環境で働く公開の操作や応答から選ぶ。 片方の環境だけで働く仕組みを使うと、ローカル検証の合否がCIと一致しなくなる。

  • SvelteKitのversion.jsonの定期確認とupdated.check()は開発時に動作しないため、更新案内(update-banner)を表示させる試験はデータ応答(__data.json)のx-sveltekit-versionをpage.routeで読み込み時と異なる値へ書き換える
  • ルートlayoutのサーバーloadがパスを参照するため、別の画面の先読みと画面遷移のたびにデータ応答が返る
  • ルートlayoutのbeforeNavigateは、新しい版を検知した後の画面遷移を再読み込みへ切り替え、再読み込み後は更新案内が出ない
  • クリックのmousedownとhoverによる先読みは遷移の前に__data.jsonを取得するので、遷移中に書き換えた版を返すと検知が遷移より先になり、応答の速いproductionで更新案内が消える
  • 書き換えた版は画面遷移の完了をURLの変化で確かめてから返し、遷移を伴わない操作(別の画面へのリンクのhoverによる先読みなど)で検知させる
  • 観測に新しい仕組みを使う場合は、make test-e2e E2E_GREP="パターン"で開発サーバーでも成功することを確かめる

When not to use it

  • →When testing native browser dialogs using Playwright's dialog event
  • →When `waitUntil: "networkidle"` is suitable for SvelteKit hydration
  • →When full mobile emulation is required for touch input D&D

Limitations

  • →It does not use Playwright's `dialog` event for custom dialogs
  • →It cannot use `waitUntil: "networkidle"` for SSE connections
  • →It does not provide full mobile emulation for touch input D&D

How it compares

This skill offers specific patterns for SvelteKit hydration and custom dialogs, and methods for network control, which differ from generic Playwright test setups.

Compared to similar skills

e2etest side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
e2etest (this skill)06moReviewIntermediate
svelte-expert111yNo flagsIntermediate
svelte-ui-design231yNo flagsIntermediate
skeleton-svelte151yNo flagsBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

svelte-expert

Raudbjorn

Expert Svelte/SvelteKit development assistant for building components, utilities, and applications. Use when creating Svelte components, SvelteKit applications, implementing reactive patterns, handling state management, working with stores, transitions, animations, or any Svelte/SvelteKit development task. Includes comprehensive documentation access, code validation with svelte-autofixer, and playground link generation.

11107

svelte-ui-design

XIYO

ALWAYS use this skill for ANY Svelte component styling, design, or UI work. Svelte 5 UI design system using Tailwind CSS 4, Skeleton Labs design tokens/presets/Tailwind Components, and Bits UI headless components. Covers class composition, color systems, interactive components, forms, overlays, and all visual design.

23136

skeleton-svelte

martinemde

Use this skill when working with Skeleton UI components in Svelte projects. It provides guidelines for Skeleton's component composition pattern, theme-aware color system, design presets, and layout patterns. Trigger when building UI components, styling elements, creating layouts, or working with Skeleton-specific features in Svelte 5 and SvelteKit 2+ projects.

15113

svelte5-development

splinesreticulating

Comprehensive Svelte 5 and SvelteKit development guidance. Use this skill when building Svelte components, working with runes, or developing SvelteKit applications. Covers reactive patterns, component architecture, routing, and data loading.

1497

sveltekit-structure

spences10

SvelteKit structure guidance. Use for routing, layouts, error handling, and SSR. Covers file naming (+page vs +layout vs +server), nested layouts, error boundaries, and hydration.

782

tanstack-form

exceptionless

TanStack Form with Zod validation in Svelte 5. Form state management, field validation, error handling, and ProblemDetails integration. Keywords: TanStack Form, createForm, Field, form validation, zod schema, form errors, onSubmit, onSubmitAsync, problemDetailsToFormErrors

1670

Search skills

Search the agent skills registry