playwright
Generate and run end-to-end tests with Playwright. Creates test journeys, runs tests, captures screenshots/videos/traces, and uploads artifacts.
SKILL.md.claude/skills/playwright/SKILL.md
GitHubPlaywright
This command invokes the e2e-runner agent to generate, maintain, and execute end-to-end tests using Playwright.
What This Command Does
- Generate Test Journeys - Create Playwright tests for user flows
- Run E2E Tests - Execute tests across browsers
- Capture Artifacts - Screenshots, videos, traces on failures
- Identify Flaky Tests - Quarantine unstable tests
When to Use
Use /playwright when:
- Testing critical user journeys (login, chat, summary)
- Verifying multi-step flows work end-to-end
- Testing UI interactions with voice/text modes
- Validating integration between frontend and Mockoon mock backend
- Preparing for production deployment
How It Works
The e2e-runner agent will:
- Analyze user flow and identify test scenarios
- Generate Playwright test following the existing test patterns
- Run tests across multiple browsers (Chromium, Firefox, WebKit)
- Capture failures with screenshots, videos, and traces
- Generate report with results and artifacts
Project Test Structure
frontend/
tests/ # E2E test files
utils.ts # Shared helpers (login, sendMessage, mockMediaDevices, etc.)
login.spec.ts # Login flow tests
signup.spec.ts # Signup flow tests
chat.spec.ts # Chat functionality (text/voice modes)
chat_history.spec.ts # Chat history display
connection.spec.ts # WebSocket connection tests
summary.spec.ts # Summary generation/display
setting.spec.ts # User settings
assistant_selection.spec.ts # Agent selection
reset_conversation.spec.ts # Conversation reset
message_duplication.spec.ts # Message dedup verification
playwright.config.ts # Playwright configuration
mock/mockoon/ # Mockoon mock API definitions
Test Conventions
Shared Utilities (tests/utils.ts)
All tests should use the shared helpers:
import { login, logoutIfNeeded, mockMediaDevices, sendMessage, waitForTextModeConnection } from './utils'
test.beforeEach(async ({ page }) => {
await mockMediaDevices(page) // Mock audio devices for voice tests
await logoutIfNeeded(page) // Ensure clean state
await login(page) // Login with test credentials
})
Test Pattern
import { expect, test } from '@playwright/test'
import { login, logoutIfNeeded, mockMediaDevices } from './utils'
test.describe('Feature name', () => {
test.beforeEach(async ({ page }) => {
await mockMediaDevices(page)
await logoutIfNeeded(page)
await login(page)
})
test('User can do X', async ({ page }) => {
// Arrange: navigate and set up
// Act: perform user action
// Assert: verify expected outcome
})
})
Key Points
- Test descriptions should follow the project's existing conventions
- Use
mockMediaDevices()for tests involving voice/audio - Use
logoutIfNeeded()before login to ensure clean state - Use
waitForTextModeConnection()orwaitForConnection()to wait for WebSocket - Use
sendMessage()helper for sending chat messages with retry logic - Environment variables:
E2E_TEST_EMAIL,E2E_TEST_PASSWORDfor test credentials
Browser Configuration
Local: Chromium + Firefox + WebKit (3 browsers)
CI: Chromium only (WebKit lacks WebRTC fake device support)
Chromium uses --use-fake-ui-for-media-stream and --use-fake-device-for-media-stream flags for microphone permission.
Running Tests
# Run with Mockoon mock backend (via dev script)
dev/test-frontend
# Run specific test file
cd frontend && npx playwright test tests/login.spec.ts
# Run in headed mode (see browser)
cd frontend && npx playwright test --headed
# Debug test
cd frontend && npx playwright test --debug
# View report
cd frontend && npx playwright show-report
Critical User Flows
Must Always Pass:
- Login with valid credentials
- Signup flow
- Text mode chat (connect → send message → receive response)
- Voice mode connection
- Chat history display
- Summary generation and display
- User settings update
Important:
- Agent/assistant selection
- Conversation reset
- Message deduplication
- Session management
Artifacts
On All Tests:
- HTML Report (
playwright-report/)
On Failure Only:
- Screenshot of the failing state
- Video recording of the test
- Trace file for debugging (step-by-step replay)
Integration with Other Commands
- Use
/planto identify critical journeys to test - Use
/tddfor unit tests (faster, more granular) - Use
/e2e-fixto diagnose and fix failing E2E tests - Use
/code-reviewto verify test quality
Related Agents
This command invokes the e2e-runner agent located at:
.claude/agents/e2e-runner.md
Language
- All user-facing output, reports, and summaries must be written in Japanese(すべてのユーザーへの出力は日本語にしてください)