import { defineConfig, devices } from '@playwright/test'; // By default the spec runs against the built app on vite preview. ORGCHAIN_URL points it at a deployed copy instead; // PW_CHANNEL=chrome uses the installed Chrome; PW_ARGS passes extra browser flags as a JSON array. const url = process.env.ORGCHAIN_URL, channel = process.env.PW_CHANNEL ? { channel: process.env.PW_CHANNEL } : {}; const launchOptions = { args: JSON.parse(process.env.PW_ARGS || '[]') }; export default defineConfig({ testDir: './tests', testMatch: '**/*.spec.js', fullyParallel: false, workers: 1, timeout: 60_000, use: { baseURL: url ?? 'http://127.0.0.1:4178/', trace: 'retain-on-failure' }, projects: [ { name: 'desktop', use: { ...devices['Desktop Chrome'], ...channel, launchOptions } }, { name: 'mobile', use: { ...devices['Pixel 7'], ...channel, launchOptions } }, ], webServer: url ? undefined : { command: 'npx vite preview --host 127.0.0.1 --port 4178 --strictPort', url: 'http://127.0.0.1:4178/', reuseExistingServer: false }, });