// Visual check helper: node scripts/screenshot.mjs [paths...] // Uses a locally installed Playwright (resolved from PLAYWRIGHT_MODULE or the default require path). import { createRequire } from 'node:module'; import { mkdirSync } from 'node:fs'; import path from 'node:path'; const require = createRequire(import.meta.url); const pwPath = process.env.PLAYWRIGHT_MODULE ?? 'playwright'; const { chromium } = require(pwPath); const [base = 'http://localhost:3000', out = '/tmp/ri-shots', ...paths] = process.argv.slice(2); const routes = paths.length ? paths : ['/', '/markets', '/markets/pokemon', '/rareindex', '/explore', '/sales', '/data']; mkdirSync(out, { recursive: true }); const browser = await chromium.launch(); for (const [label, viewport, theme] of [ ['desktop-light', { width: 1440, height: 900 }, 'light'], ['desktop-dark', { width: 1440, height: 900 }, 'dark'], ['mobile-light', { width: 390, height: 844 }, 'light'], ]) { const ctx = await browser.newContext({ viewport, deviceScaleFactor: 1, colorScheme: theme }); await ctx.addInitScript((t) => localStorage.setItem('ri-theme', t), theme); const page = await ctx.newPage(); for (const r of routes) { await page.goto(base + r, { waitUntil: 'networkidle', timeout: 120_000 }); const file = path.join(out, `${label}${r === '/' ? '-home' : r.replace(/[^a-z0-9]+/gi, '-')}.png`); await page.screenshot({ path: file, fullPage: true }); console.log('saved', file); } await ctx.close(); } await browser.close();