import { fileURLToPath } from 'node:url' import path from 'node:path' import { defineConfig, devices } from '@playwright/test' import { getTestServerPort } from '@tanstack/router-e2e-utils' import packageJson from './package.json' with { type: 'json' } // Ensure port file is written next to this config, even if Playwright loads it // from a different working directory. process.chdir(path.dirname(fileURLToPath(import.meta.url))) const PORT = await getTestServerPort(packageJson.name) const baseURL = `http://localhost:${PORT}` /** * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ testDir: './tests', workers: 1, reporter: [['line']], use: { /* Base URL to use in actions like `await page.goto('/')`. */ baseURL, }, webServer: { command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, }, ], })