No. 105 Pin the behavior
Visual Testing with Playwright
Use when the behavior should be pinned by a test, not only by a reading of the diff
- Claude Code
- Codex
- Cursor
- Pin the behavior
# Visual Testing with Playwright Use Playwright to visually test your recent UI changes. ## MCP Server Integration If you have the Playwright MCP server configured (via .mcp.json), Claude Code can: - Navigate to your app and take screenshots - Interact with elements directly - Generate Playwright test code - Run visual comparisons To use: Simply describe what you want to test and Claude Code will use the Playwright MCP server if available. ## Testing Tasks 1. **Identify what to test** - List all UI components you've modified - Note any new user flows or interactions - Consider responsive design breakpoints 2. **Run visual tests** - Use Playwright's screenshot capabilities - Test in multiple browsers (Chromium, Firefox, WebKit) - Capture different states (loading, error, success) - Test both light and dark modes if applicable 3. **Interaction testing** - Click through user workflows - Test form submissions - Verify animations and transitions - Check hover states and focus indicators 4. **Accessibility checks** - Verify keyboard navigation works - Test with screen reader announcements - Check color contrast ratios - Ensure proper ARIA labels 5. **Cross-browser validation** - Compare rendering across browsers - Test on different viewport sizes - Verify consistent behavior ## Commands to use Check your project's test scripts and documentation. Common patterns include: ```bash # Examples - adapt to your project's setup: # npm run test:visual # yarn test:e2e # pnpm test:playwright # python -m pytest tests/visual # bundle exec rspec spec/features # ./gradlew test # For Playwright specifically (if using): # npx playwright test --update-snapshots # playwright test --ui ``` ## What to look for - Layout shifts or broken designs - Missing styles or incorrect colors - Overlapping elements - Text that's cut off or wrapped incorrectly - Interactive elements that don't respond - Loading states that get stuck - Error messages that don't display properly Remember to commit any new or updated snapshot files if the visual changes are intentional!
When to use
“Visual Testing with Playwright” fits when the behavior should be pinned by a test, not only by a reading of the diff, because it says “Visual Testing with Playwright”, and its first written step is “Identify what to test”.
For “Visual Testing with Playwright”, the extra line you type is the requirement those steps ask for, for example “make src/cart.js return 0 on an empty cart and skip a line with no price”, and the file then starts at “Identify what to test”.
When not to use
Leave “Visual Testing with Playwright” unused when you already have the failing test in front of you and you wanted it explained, because “Visual Testing with Playwright” points the other way
How to run it
Claude Code
Claude Code stores “Visual Testing with Playwright” as a Claude command and runs it with that command, putting the requirement in the argument, and CLAUDE.md should not also carry “Visual Testing with Playwright”.
Codex
Codex takes “Visual Testing with Playwright” as a paste above the task. Leave AGENTS.md unchanged so the next thread does not inherit “Visual Testing with Playwright”.
Cursor
Cursor should see “Visual Testing with Playwright” only as a chat paste of “Visual Testing with Playwright” for this turn. A file at .cursor/rules would keep applying after the turn ends.
Comparison
对比待补
This before-and-after was not run on this machine.
Related
- Stage: Pin the behavior
- Same stage: You are an expert QA engineer with deep knowledge of…
来源:Darin Cassler · https://github.com/cassler/awesome-claude-code-setup/blob/main/commands/visual-test.md · MIT · Copyright (c) 2025 Darin Cassler · 2026-12-01