lilith-platform.live/codebase/@features/landing/frontend-public/playwright.config.ts
Claude Code 25d2c7ad65 init(codebase-default): 🎉 Implement foundational directory structure with core modules and utility files
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-03-25 22:50:24 -07:00

79 lines
2.3 KiB
TypeScript
Executable file

/**
* Playwright E2E Configuration for Landing App (Local Development)
*
* Uses @lilith/playwright-e2e-docker config factory for consistency.
* For Docker-based testing, use playwright.docker.config.ts
*
* Self-contained: globalSetup starts PostgreSQL (Docker) + backend API.
* globalTeardown stops them. Frontend is started by Playwright's webServer.
*
* Usage:
* pnpm test:e2e - Run with auto-started services
* pnpm test:e2e:docker - Run with full Docker stack (CI)
*/
import { createPlaywrightConfig } from '@lilith/playwright-e2e-docker'
// Enable analytics tests — the webServer command builds with VITE_ANALYTICS_ENABLED=true
process.env.ANALYTICS_TESTS_ENABLED = 'true'
const baseConfig = createPlaywrightConfig({
// Test configuration
testDir: './e2e/tests',
testMatch: /.*\.spec\.ts/,
appName: 'landing',
// Timeouts
timeout: 60000,
expectTimeout: 10000,
actionTimeout: 15000,
navigationTimeout: 30000,
// Parallelization
fullyParallel: true,
workers: 4,
// Retries
retries: 2,
// Device preset
devicePreset: 'chromium-only',
// Base URL - uses Vite preview port (5101 to avoid conflict with atlilith.www on 5100)
baseURL: 'http://localhost:5101',
// Web server configuration (local development)
// Builds with analytics enabled so analytics E2E tests can run
webServer: {
command: 'VITE_QA_API_URL=http://localhost:5101 VITE_ANALYTICS_ENABLED=true bun run build && bun run preview --host --port 5101',
port: 5101,
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
// Recording
video: 'retain-on-failure',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
// Output directory
outputDir: 'test-results/landing',
})
export default {
...baseConfig,
// Block service workers so Playwright page.route() can intercept API requests.
// The production build registers an i18n cache service worker and includes MSW's
// mockServiceWorker.js. Service workers intercept fetch before Playwright's route
// handlers, preventing API mocking from working.
use: {
...baseConfig.use,
serviceWorkers: 'block' as const,
},
// Service orchestration: start PostgreSQL + backend before tests,
// tear them down after tests complete
globalSetup: './e2e/setup/playwright-global-setup.ts',
globalTeardown: './e2e/setup/playwright-global-teardown.ts',
}