|
| 1 | +/* eslint-disable line-comment-position */ |
| 2 | +/* eslint-disable no-restricted-imports */ |
| 3 | +import {defineConfig} from '@playwright/test' |
| 4 | +import * as fs from 'fs' |
| 5 | +import * as path from 'path' |
| 6 | +import {fileURLToPath} from 'url' |
| 7 | + |
| 8 | +const __dirname = path.dirname(fileURLToPath(import.meta.url)) |
| 9 | + |
| 10 | +// Load .env file if present (CI provides env vars directly) |
| 11 | +const envPath = path.join(__dirname, '.env') |
| 12 | +if (fs.existsSync(envPath)) { |
| 13 | + for (const line of fs.readFileSync(envPath, 'utf-8').split('\n')) { |
| 14 | + const trimmed = line.trim() |
| 15 | + if (!trimmed || trimmed.startsWith('#')) continue |
| 16 | + const eqIdx = trimmed.indexOf('=') |
| 17 | + if (eqIdx === -1) continue |
| 18 | + const key = trimmed.slice(0, eqIdx).trim() |
| 19 | + const value = trimmed.slice(eqIdx + 1).trim() |
| 20 | + process.env[key] ??= value |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +const isCI = Boolean(process.env.CI) |
| 25 | + |
| 26 | +export default defineConfig({ |
| 27 | + testDir: './tests', |
| 28 | + fullyParallel: false, |
| 29 | + forbidOnly: isCI, |
| 30 | + retries: 0, |
| 31 | + workers: 1, |
| 32 | + maxFailures: isCI ? 3 : 0, // Stop early in CI after 3 failures |
| 33 | + reporter: isCI ? [['html', {open: 'never'}], ['list']] : [['list']], |
| 34 | + timeout: 3 * 60 * 1000, // 3 minutes per test |
| 35 | + globalTimeout: 15 * 60 * 1000, // 15 minutes total |
| 36 | + |
| 37 | + use: { |
| 38 | + trace: isCI ? 'on' : 'off', |
| 39 | + screenshot: isCI ? 'on' : 'off', |
| 40 | + video: 'off', |
| 41 | + }, |
| 42 | +}) |
0 commit comments