Summary
Playwright E2Eテストフレームワークの判断軸。ユーザー視点のロケーター選択・自動待機・テスト分離・CI最適化を公式ベストプラクティスに沿って整理する。Playwright、E2Eテスト、ブラウザテスト、インテグレーションテスト、getByRole、ロケーター設計、テストの安定性、CI上のテスト失敗に関する相…
mae616/ai-tech-knowledge · Archived
Playwright E2Eテストフレームワークの判断軸。ユーザー視点のロケーター選択・自動?
npx skills add mae616/ai-tech-knowledge --skill playwright
Playwright E2Eテストフレームワークの判断軸。ユーザー視点のロケーター選択・自動待機・テスト分離・CI最適化を公式ベストプラクティスに沿って整理する。Playwright、E2Eテスト、ブラウザテスト、インテグレーションテスト、getByRole、ロケーター設計、テストの安定性、CI上のテスト失敗に関する相…
This repository is archived — consider an actively maintained alternative.
Tailwind CSSをutility-first(早すぎる抽象化を避ける)思想で運用し、UI実?
6 installsReact/Next.jsプロジェクトで、UI=計算モデル(コンポーネント/状態/レンダリング)を軸に、設計・実…
5 installsp5.js(クリエイティブコーディング)のProcessing由来「コードでスケッチ」思想を軸に、setup/drawル…
4 installsGSAP(GreenSock Animation Platform)のTween/Timeline/ScrollTrigger/Easingを軸に、ウェブアニメー…
4 installsRelated neighbors and high-traction skills in the same topics — useful to compare before installing.
Browser automation CLI for AI agents. Use when the user needs to interact with websites, includ…
810.4K installsDebug Azure production issues on Azure using AppLens, Azure Monitor, resource health, and safe …
568.9K installsPre-deployment validation for Azure readiness. Run deep checks on configuration, infrastructure…
567.7K installsConfigure Azure API Management as an AI Gateway for AI models, MCP tools, and agents. WHEN: sem…
566.3K installsAzure VM/VMSS router. WHEN: create / provision / deploy / spin-up VM, recommend VM size, compar…
510K installsPostgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill …
391.6K installsOther skills from mae616/ai-tech-knowledge.
npx skills add mae616/ai-tech-knowledge
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
main
Files included with this skill beyond the listing page.
SKILL.md
6,808 B
SUMMARY.md
685 B
getByRole > getByLabel > getByText > getByTestId > CSSセレクタ。ロールベースを最優先。isVisible() チェックを避ける。getByRole('button', { name: '送信' }) はリファクタに強い。CSSセレクタはDOMの変更で壊れる。sleep や waitForTimeout は不要。on: 'first-retry' で有効化。// 1. ロールベース(最優先・推奨)
page.getByRole('button', { name: '送信' })
page.getByRole('textbox', { name: 'メールアドレス' })
page.getByRole('heading', { name: 'ログイン' })
// 2. ラベル/プレースホルダー
page.getByLabel('メールアドレス')
page.getByPlaceholder('[email protected]')
// 3. テキスト
page.getByText('ログイン')
// 4. テストID(他の方法で特定できない場合)
page.getByTestId('submit-button')
// 5. CSSセレクタ(最終手段)
page.locator('#submit-btn')
// 推奨: Web Firstアサーション(自動リトライ付き)
await expect(page.getByText('ようこそ')).toBeVisible()
await expect(page.getByRole('alert')).toHaveText('保存しました')
await expect(page).toHaveURL('/dashboard')
// 非推奨: 手動チェック(リトライなし)
expect(await page.getByText('ようこそ').isVisible()).toBe(true)
import { test, expect } from '@playwright/test'
test.describe('ログインフロー', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login')
})
test('正常系_有効な認証情報でダッシュボードに遷移', async ({ page }) => {
await page.getByLabel('メールアドレス').fill('[email protected]')
await page.getByLabel('パスワード').fill('password123')
await page.getByRole('button', { name: 'ログイン' }).click()
await expect(page).toHaveURL('/dashboard')
})
test('異常系_無効なパスワードでエラー表示', async ({ page }) => {
await page.getByLabel('メールアドレス').fill('[email protected]')
await page.getByLabel('パスワード').fill('wrong')
await page.getByRole('button', { name: 'ログイン' }).click()
await expect(page.getByRole('alert')).toHaveText('認証に失敗しました')
})
})
// playwright.config.ts のCI向け設定
export default defineConfig({
// CIでは全リトライ1回
retries: process.env.CI ? 1 : 0,
// CIでは並列ワーカーを制限
workers: process.env.CI ? 2 : undefined,
// Traceは最初のリトライ時のみ
use: {
trace: 'on-first-retry',
},
})
# CIで必要なブラウザだけインストール
npx playwright install --with-deps chromium
# シャーディングで並列化
npx playwright test --shard=1/3
npx playwright test --shard=2/3
npx playwright test --shard=3/3
getByRole)を最優先にしているかawait expect(...).toBeVisible() 等)かwaitForTimeout / sleep を使っていないかon-first-retry).btn-primary)に依存してリファクタで全壊するpage.waitForTimeout(3000) でCI環境の速度差を吸収しようとする(不安定の根本原因)