import { defineConfig } from '@playwright/test' import { parsePagePaths } from '../shared/paths.ts' const IS_CI = !!process.env.CI const PAGE_COUNT = parsePagePaths(process.env.DOCS_E2E_PAGE_PATHS).length const A11Y_FAILURES_FILE = process.env.DOCS_A11Y_FAILURES_FILE export default defineConfig({ testDir: './features', testMatch: /.*\.spec\.ts/, timeout: 60_000, forbidOnly: IS_CI, retries: IS_CI ? 2 : 0, expect: { timeout: 15_000, }, fullyParallel: false, workers: PAGE_COUNT > 20 ? 3 : 1, use: { baseURL: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:3001', browserName: 'chromium', headless: true, navigationTimeout: 30_000, screenshot: 'only-on-failure', trace: 'retain-on-failure', video: 'off', extraHTTPHeaders: process.env.VERCEL_AUTOMATION_BYPASS_SECRET ? { 'x-vercel-protection-bypass': process.env.VERCEL_AUTOMATION_BYPASS_SECRET, 'x-vercel-set-bypass-cookie': 'true', } : undefined, }, projects: [ { name: 'Features', testDir: './features', testMatch: /.*\.spec\.ts/, use: { browserName: 'chromium', }, }, ], reporter: [ ['list'], ['html', { open: 'never', outputFolder: './playwright-report' }], ...(IS_CI ? [] : [['json', { outputFile: './test-results/test-results.json' }] as const]), ...(A11Y_FAILURES_FILE ? [['./utils/a11y-failures-reporter.ts', { outputFile: A11Y_FAILURES_FILE }] as const] : []), ], outputDir: './test-results', })