import { defineConfig } from '@playwright/test'; import * as fs from 'fs'; import { fileURLToPath } from 'url'; import * as path from 'path'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Load TT_BASE_URL from data/test/.env if not already set const envFile = path.resolve(__dirname, '../data/test/.env'); if (fs.existsSync(envFile)) { for (const line of fs.readFileSync(envFile, 'utf-8').split('\n')) { const eq = line.indexOf('='); if (eq > 0) { const key = line.slice(0, eq).trim(); if (!process.env[key]) process.env[key] = line.slice(eq + 1).trim(); } } } const baseURL = process.env.TT_BASE_URL ?? 'http://127.0.0.1:3000'; export default defineConfig({ globalSetup: './tests/global-setup.ts', testDir: './tests', workers: 1, reporter: [ ['list'], ['html', { open: 'never', outputFolder: 'playwright-report' }], ], use: { baseURL, storageState: 'tests/.auth/admin.json', }, webServer: { command: 'make -C .. test-up', url: `${baseURL}/health`, reuseExistingServer: true, timeout: 60_000, }, });