Files
opencode-manager/e2e/playwright.config.ts
Chris Scott b431c121a2 test(e2e): start the E2E backend with only the variables the suite defines
The E2E backend inherited the caller's environment and Bun auto-loaded .env
files from the repo root, so local credentials and host variables could leak
into the run. server.sh now launches the backend with env -i, passing PATH and
only the keys from createServerEnv (E2E_SERVER_ENV_KEYS), runs bun with
--no-env-file, and starts it from a scratch directory with a frontend symlink
so no .env file is in reach.
2026-10-23 22:44:22 -04:00

51 lines
1.3 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test'
import { BASE_URL, E2E_ROOT, REPORT_DIR, REPO_ROOT, STORAGE_STATE, TEST_RESULTS_DIR, createServerEnv } from './env'
const serverEnv = createServerEnv()
export default defineConfig({
testDir: E2E_ROOT,
outputDir: TEST_RESULTS_DIR,
fullyParallel: false,
forbidOnly: Boolean(process.env.CI),
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
timeout: 60_000,
expect: { timeout: 15_000 },
reporter: [
['list'],
['html', { open: 'never', outputFolder: REPORT_DIR }],
['./cleanup-reporter.ts'],
],
use: {
baseURL: BASE_URL,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
projects: [
{
name: 'setup',
testMatch: /auth\.setup\.ts/,
},
{
name: 'chromium',
testMatch: /.*\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
storageState: STORAGE_STATE,
},
dependencies: ['setup'],
},
],
webServer: {
command: 'bash e2e/server.sh',
cwd: REPO_ROOT,
url: `${BASE_URL}/api/health`,
timeout: 180_000,
reuseExistingServer: false,
gracefulShutdown: { signal: 'SIGTERM', timeout: 15_000 },
env: { ...serverEnv, E2E_SERVER_ENV_KEYS: Object.keys(serverEnv).join(' ') },
},
})