Visual Testing
1.0.0Screenshot diffs and regression workflows for landing and dashboard apps.
On this page
- π¨ Visual Regression Testing Implementation Complete
- β What's Been Implemented
- 1. Playwright Visual Testing for Storybook
- 2. Detox Visual Testing for React Native
- 3. CI/CD Integration
- 4. Developer Tools
- π Quick Start Commands
- π Test Coverage
- Web Components (Playwright + Storybook)
- Mobile Screens (Detox + React Native)
- π CI Workflow
- π File Structure
- π― Benefits
- For Developers
- For QA/Design
- For CI/CD
- π§ Maintenance
- Updating Baselines
- Adding New Tests
- Troubleshooting
- π Success Metrics
- π Next Steps
π¨ Visual Regression Testing Implementation Complete
β What's Been Implemented
1. Playwright Visual Testing for Storybook
- Configuration:
playwright.config.tswith multi-browser support - Test Suite:
tests/visual/storybook.spec.tscovering all UI components - Coverage: 50+ visual tests across Button, Card, Input, List, Navigation, etc.
- Responsive: Mobile, tablet, desktop viewports
- Themes: Light and dark mode variations
- Browsers: Chrome, Firefox, Safari, Mobile Chrome, Mobile Safari
2. Detox Visual Testing for React Native
- Configuration:
.detoxrc.jsfor Focus AI and Health Tracker apps - Test Suites: Separate test files for each mobile app
- Coverage: Home, Settings, Paywall screens with component showcases
- Orientations: Portrait and landscape testing
- Themes: Light and dark mode support
- Platform: Android emulator with screenshot capabilities
3. CI/CD Integration
- GitHub Actions:
.github/workflows/visual-regression.yml - Automated Testing: Runs on PRs and main branch pushes
- Artifact Upload: Screenshots, reports, and test results
- PR Comments: Automated visual diff reporting
- Multi-Stage: Web and mobile tests run in parallel
4. Developer Tools
- Helper Script:
scripts/visual-tests.mjsfor easy management - Package Scripts: Convenient npm/pnpm commands
- Turbo Integration: Build pipeline optimization
- Documentation: Comprehensive guide in
VISUAL_TESTING_GUIDE.md
π Quick Start Commands
# Setup everything
pnpm visual-tests setup
# Run web tests
pnpm visual-tests run-web
# Run mobile tests
pnpm visual-tests run-mobile
# Update baselines when UI changes
pnpm visual-tests update-baselines
π Test Coverage
Web Components (Playwright + Storybook)
- β Button: 12 stories (variants, sizes, states, icons)
- β Card: 8 stories (variants, padding, interactive, custom content)
- β Input: 15 stories (variants, sizes, validation, forms)
- β List: 5 stories (icons, sections, interactive)
- β Navigation: 3 stories (horizontal, vertical, with icons)
- β Onboarding: 2 stories (default, with progress)
- β Paywall: 2 stories (default, premium)
- β PricingTable: 2 stories (default, highlighted)
- β Settings: 2 stories (default, with sections)
- β ThemeSwitcher: 2 stories (default, compact)
Mobile Screens (Detox + React Native)
- β Focus AI: Home, Settings, Paywall screens
- β Health Tracker: Home, Settings, Paywall screens
- β Component Showcases: Button, Card, Input variations
- β Dark Mode: All screens in dark theme
- β Orientations: Portrait and landscape
π CI Workflow
- Trigger: PR created/updated or push to main/develop
- Setup: Install dependencies, browsers, Android SDK
- Build: Compile UI packages and mobile apps
- Test Web: Run Playwright tests against Storybook
- Test Mobile: Run Detox tests on Android emulator
- Report: Upload artifacts and comment on PR
- Diff: Show visual differences for review
π File Structure
app-factory/
βββ .github/workflows/visual-regression.yml # CI configuration
βββ playwright.config.ts # Playwright config
βββ .detoxrc.js # Detox configuration
βββ tests/visual/storybook.spec.ts # Web visual tests
βββ e2e/
β βββ jest.config.js # Jest config for Detox
β βββ init.ts # Detox setup
β βββ focus-ai-visual.test.ts # Focus AI tests
β βββ health-tracker-visual.test.ts # Health Tracker tests
βββ scripts/visual-tests.mjs # Helper script
βββ VISUAL_TESTING_GUIDE.md # Comprehensive guide
βββ README_VISUAL_TESTING.md # This summary
π― Benefits
For Developers
- Early Detection: Catch UI regressions before they reach production
- Confidence: Know that UI changes don't break existing components
- Documentation: Visual documentation of all component states
- Automation: No manual testing needed for visual consistency
For QA/Design
- Visual Diffs: Clear before/after comparisons
- Cross-Browser: Ensure consistency across all browsers
- Mobile Testing: Automated mobile app screenshot testing
- Baseline Management: Easy approval of intentional changes
For CI/CD
- Automated: Runs automatically on every PR
- Fast Feedback: Quick visual regression detection
- Artifacts: Screenshots and reports for debugging
- Integration: Works with existing GitHub workflow
π§ Maintenance
Updating Baselines
When you make intentional UI changes:
- Review Changes: Check what visual differences exist
- Validate: Ensure changes are correct and intentional
- Update: Run
pnpm visual-tests update-baselines - Commit: Add updated baseline images to git
Adding New Tests
For new components or screens:
- Storybook: Add comprehensive stories for web components
- Test IDs: Add testID props to React Native screens
- Test Files: Update test files with new scenarios
- Baselines: Run tests to generate initial baselines
Troubleshooting
- Flaky Tests: Increase threshold or wait times
- Browser Issues: Update Playwright browsers
- Mobile Issues: Check Android emulator setup
- CI Failures: Review logs and artifacts
π Success Metrics
With this implementation, you now have:
- β 50+ Visual Tests covering all key UI components
- β Multi-Platform testing (web + mobile)
- β Multi-Browser support (5 different browsers/viewports)
- β Automated CI with PR diff reporting
- β Developer Tools for easy management
- β Comprehensive Documentation for team onboarding
π Next Steps
- Install Dependencies: Run
pnpm installto get new packages - Setup Environment: Run
pnpm visual-tests setup - Generate Baselines: Run initial tests to create baseline images
- Team Training: Share
VISUAL_TESTING_GUIDE.mdwith the team - CI Integration: Merge and watch CI run visual tests on PRs
Your visual regression testing infrastructure is now complete! π