import { defineConfig } from '@playwright/test'; // Where browsers run and how the app is addressed: // (default) browsers on the shared remote Playwright server (Docker, 192.168.1.4:3000); // app = prod build behind Traefik at https://flight.dev.kkhost.pl (docker compose). // NOTE: don't point this at `next dev` over the LAN — Turbopack's HMR WS fails for // non-loopback clients and the page renders blank. // E2E_LOCAL=1 everything local — browsers here, `npm run dev` on localhost:3000 // (fast iteration; fallback when remote server or proxy is down). // E2E_REMOTE=1 runner not on this box: skip webServer; pair with E2E_BASE_URL if needed. const local = process.env.E2E_LOCAL === '1'; const remoteRunner = process.env.E2E_REMOTE === '1'; if (!local && !process.env.PW_TEST_CONNECT_WS_ENDPOINT) { process.env.PW_TEST_CONNECT_WS_ENDPOINT = 'ws://192.168.1.4:3000/'; } export default defineConfig({ testDir: './e2e', timeout: 30_000, retries: 1, use: { baseURL: process.env.E2E_BASE_URL ?? (local ? 'http://localhost:3000' : 'https://flight.dev.kkhost.pl'), trace: 'on-first-retry', }, webServer: remoteRunner ? undefined : local ? { command: 'npm run dev', url: 'http://localhost:3000/api/airports', reuseExistingServer: true, timeout: 120_000, } : { command: 'docker compose up -d --build', url: 'https://flight.dev.kkhost.pl/api/airports', reuseExistingServer: true, timeout: 300_000, }, });