| 1 | // @ts-check |
| 2 | /** |
| 3 | * Playwright configuration for SquadScope design visual verification. |
| 4 | * |
| 5 | * This config is scoped to tests/visual/ only — it is NOT the project-wide |
| 6 | * test runner. It runs against a locally running Hugo server. |
| 7 | * |
| 8 | * Usage: |
| 9 | * # Start Hugo first: |
| 10 | * hugo server -D --bind 0.0.0.0 |
| 11 | * |
| 12 | * # Generate / update baselines (run once on main branch): |
| 13 | * npx playwright test --config tests/visual/playwright.config.mjs --update-snapshots |
| 14 | * |
| 15 | * # Run comparison (on PR branch): |
| 16 | * npx playwright test --config tests/visual/playwright.config.mjs |
| 17 | */ |
| 18 | |
| 19 | import { defineConfig, devices } from '@playwright/test'; |
| 20 | |
| 21 | export default defineConfig({ |
| 22 | testDir: '.', // relative to this config file: tests/visual/ |
| 23 | snapshotDir: 'snapshots', |
| 24 | outputDir: '../../screenshots/playwright-output', |
| 25 | |
| 26 | // Retry once on CI to reduce font-rendering flakiness |
| 27 | retries: process.env.CI ? 1 : 0, |
| 28 | |
| 29 | // Run tests sequentially — Hugo is on localhost, parallelism adds noise |
| 30 | workers: 1, |
| 31 | |
| 32 | use: { |
| 33 | baseURL: process.env.BASE_URL ?? 'http://localhost:1313/SquadScope', |
| 34 | // Wait for network to settle before screenshotting |
| 35 | actionTimeout: 15000, |
| 36 | }, |
| 37 | |
| 38 | expect: { |
| 39 | toHaveScreenshot: { |
| 40 | // Allow ~150 pixel diff for anti-aliasing and sub-pixel font rendering |
| 41 | maxDiffPixels: 150, |
| 42 | // Timeout for screenshot comparison |
| 43 | timeout: 10000, |
| 44 | }, |
| 45 | }, |
| 46 | |
| 47 | projects: [ |
| 48 | // Desktop — light |
| 49 | { |
| 50 | name: 'desktop-light', |
| 51 | use: { |
| 52 | ...devices['Desktop Chrome'], |
| 53 | viewport: { width: 1280, height: 800 }, |
| 54 | colorScheme: 'light', |
| 55 | }, |
| 56 | }, |
| 57 | // Desktop — dark |
| 58 | { |
| 59 | name: 'desktop-dark', |
| 60 | use: { |
| 61 | ...devices['Desktop Chrome'], |
| 62 | viewport: { width: 1280, height: 800 }, |
| 63 | colorScheme: 'dark', |
| 64 | }, |
| 65 | }, |
| 66 | // Mobile — light |
| 67 | { |
| 68 | name: 'mobile-light', |
| 69 | use: { |
| 70 | ...devices['iPhone 13'], |
| 71 | colorScheme: 'light', |
| 72 | }, |
| 73 | }, |
| 74 | // Mobile — dark |
| 75 | { |
| 76 | name: 'mobile-dark', |
| 77 | use: { |
| 78 | ...devices['iPhone 13'], |
| 79 | colorScheme: 'dark', |
| 80 | }, |
| 81 | }, |
| 82 | // Wide — light (for the wide editorial layout) |
| 83 | { |
| 84 | name: 'wide-light', |
| 85 | use: { |
| 86 | ...devices['Desktop Chrome'], |
| 87 | viewport: { width: 1920, height: 1080 }, |
| 88 | colorScheme: 'light', |
| 89 | }, |
| 90 | }, |
| 91 | // Wide — dark |
| 92 | { |
| 93 | name: 'wide-dark', |
| 94 | use: { |
| 95 | ...devices['Desktop Chrome'], |
| 96 | viewport: { width: 1920, height: 1080 }, |
| 97 | colorScheme: 'dark', |
| 98 | }, |
| 99 | }, |
| 100 | ], |
| 101 | }); |