フロントエンドのテスト基盤構築計画 #4968
KentaHizume
started this conversation in
03: アイディア
Replies: 2 comments
-
Codex5.3レビュー結果(Findings 優先)
Open Questions / Assumptions
総評
必要なら次のステップとして、上記 3 点を反映した「Issue テンプレート文面(そのまま起票できる版)」を作成します。 |
Beta Was this translation helpful? Give feedback.
0 replies
-
テストの理論
単体テスト(Vitest(jsdom))
結合テスト(コンポーネントテスト)( Vitest /Vitest Browser )
VRT(Vitest)
E2E(Playwright)
カバレッジ指標
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
はじめに
計画のための壁打ちの記録を残します。
Claude Opus 4.6
Plan: dressca-frontend 自動テスト環境構築
テスティングトロフィー(静的解析 → 単体テスト → コンポーネント/統合テスト(最大比重) → E2E テスト)の方針に基づき、Vitest Browser Mode + Playwright + MSW による多層テスト環境を段階的に構築する。
現状
Issue #1: [基盤] Vitest ブラウザーモードの導入と設定
概要: コンポーネントテスト・VRT の基盤として
@vitest/browserを導入する。作業内容:
@vitest/browser,playwrightvitest.workspace.tsを作成し、4 プロジェクト定義:consumer:unit/admin:unit— jsdom 環境(既存テスト)consumer:browser/admin:browser— Playwright chromium 環境browser.provider: 'playwright',browser.instances: [{ browser: 'chromium' }])@vitest/browser型定義追加*.spec.ts(既存)、コンポーネント*.browser.spec.ts、VRT*.vrt.spec.tsvitest.setup.browser.ts作成(MSWsetupWorker用セットアップ)test:component,test:vrtスクリプト追加関連ファイル:
Issue #2: [基盤] Playwright の導入と E2E テスト環境構築
概要: Cypress に代わる E2E テストフレームワークとして
@playwright/testを導入する。作業内容:
@playwright/testをインストールplaywright.config.tsを作成:webServerでnpm run mockを自動起動(MSW モックモード)baseURL: consumer →http://localhost:5173, admin →http://localhost:6173testDir: './e2e'projects: chromium(CI では firefox/webkit 追加可能)retries: CI 環境では 2e2e/ディレクトリ作成test:e2e,test:e2e:uiスクリプト追加関連ファイル:
consumer/playwright.config.ts,admin/playwright.config.tsconsumer/e2e/,admin/e2e/Issue #3: [基盤] Consumer アプリの MSW Node セットアップ
概要: Consumer に node.ts と vitest.setup.ts の MSW サーバー起動を追加し、admin とのパリティを確保する。
作業内容:
consumer/mock/node.tsを作成(setupServer(...handlers)パターン、node.ts を参照)server.listen()/server.resetHandlers()/server.close()追加(vitest.setup.ts を参照)関連ファイル:
consumer/mock/node.tsIssue #4: [テスト実装] コンポーネントテストの作成(Vitest ブラウザーモード)
前提: Issue #1, #3 完了
概要: テスティングトロフィーの最大比重であるコンポーネントテストを実ブラウザ上で実装する。
作業内容:
CatalogViewBasketViewCheckoutViewCarouselSliderItemsViewItemsAddViewItemsEditViewLoginViewテスト方針:
Issue #5: [テスト実装] VRT(Visual Regression Testing)の構築
前提: Issue #1 完了
概要: Vitest ブラウザーモードのスクリーンショット機能を活用し、UI の意図しない視覚的変更を検出する。
作業内容:
toMatchImageSnapshot()またはカスタムマッチャーの構成.vrt-snapshots/ディレクトリに格納、Git にコミットtest:vrt:updateコマンドでスナップショット更新Issue #6: [テスト実装] E2E テストの作成(Playwright)
前提: Issue #2 完了
概要: テスティングトロフィーの方針に基づき、最も重要なユーザーフローに絞って E2E テストを実装する。
作業内容:
テスト方針:
npm run mock)でアプリ起動(バックエンド不要)Issue #7: [CI/CD] GitHub Actions ワークフローの更新
前提: Issue #4, #5, #6 完了
概要: 新テストタイプを既存 CI パイプラインに統合する。
作業内容:
npx playwright install --with-deps chromiumステップ追加pathsフィルター更新(新テストファイル対応)関連ファイル:
.github/workflows/samples-dressca-consumer-frontend.ci.yml.github/workflows/samples-dressca-admin-frontend.ci.ymlIssue #8: [クリーンアップ] Cypress の削除
前提: Issue #6, #7 完了(Playwright E2E が CI で安定稼働)
概要: Cypress 関連の依存関係と設定をすべて削除する。
作業内容:
eslint-plugin-cypress,start-server-and-testcypress.config.*参照削除pluginCypressインポート・設定)test:e2e,test:e2e:ci,prepare)依存関係と実行順序
技術判断
toMatchImageSnapshotnpm run mock)さらなる検討事項
コンポーネントテストで
@testing-library/vueを採用するか? — 現状は@vue/test-utilsを使用中。ブラウザーモードでは@testing-library/vueのユーザー中心のアプローチがテスティングトロフィーとより親和性が高い。推奨: ブラウザーモードのコンポーネントテストには@testing-library/vueを新規採用し、既存 jsdom テストはそのまま維持VRT のスナップショットを OS 間で安定させるための対策 — フォントレンダリングの差異により、ローカル (Windows) と CI (Ubuntu) で VRT が不安定になる可能性がある。推奨: VRT のベースライン生成・比較は Docker コンテナまたは CI 環境のみで実施し、ローカルでは
test:vrt:updateを手動実行するフローとするPlaywright E2E テストの対象ブラウザー数 — テスティングトロフィーでは E2E は最小限が望ましい。推奨: CI では chromium のみ、必要に応じて firefox/webkit を段階的に追加
Beta Was this translation helpful? Give feedback.
All reactions