import { defineConfig, devices } from '@playwright/test'; import { fileURLToPath } from 'node:url'; import { dirname, resolve } from 'node:path'; /** * Written without `@nx/playwright`'s preset on purpose: Playwright loads this * file through Node's ESM loader, and pulling in `@nx/devkit` from there drags * Nx's native binding in under `runSync`, where it fails to initialise. Only * `testDir`, `outputDir` and the web server came from the preset anyway. */ const here = dirname(fileURLToPath(import.meta.url)); const workspaceRoot = resolve(here, '..'); const baseURL = process.env['BASE_URL'] || 'http://localhost:4200'; export default defineConfig({ testDir: './src', outputDir: resolve(workspaceRoot, 'dist/.playwright/landing-e2e/test-output'), timeout: 60_000, forbidOnly: !!process.env['CI'], retries: process.env['CI'] ? 2 : 0, workers: process.env['CI'] ? 1 : undefined, reporter: [['list']], use: { baseURL, trace: 'on-first-retry', }, webServer: { command: 'npx nx run landing:serve', url: baseURL, reuseExistingServer: true, timeout: 180_000, cwd: workspaceRoot, }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, }, ], });