mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
36 lines
1.6 KiB
TypeScript
36 lines
1.6 KiB
TypeScript
import { defineConfig, devices } from "@playwright/test"
|
|
|
|
const port = Number(process.env.PLAYWRIGHT_STORIES_PORT ?? 6006)
|
|
const baseURL = process.env.PLAYWRIGHT_STORIES_URL ?? `http://127.0.0.1:${port}`
|
|
|
|
export function componentConfig(directory: string) {
|
|
return defineConfig({
|
|
testDir: `${directory}/component-tests`,
|
|
outputDir: `${directory}/component-tests/test-results`,
|
|
timeout: 60_000,
|
|
expect: { timeout: 10_000 },
|
|
fullyParallel: true,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: process.env.CI ? 2 : undefined,
|
|
reporter: [["html", { outputFolder: `${directory}/component-tests/playwright-report`, open: "never" }], ["line"]],
|
|
webServer: {
|
|
// Vite runs on Node: Bun 1.4.2's node:http crashes the server with an uncaught "write after end" when a browser
|
|
// abandons pipelined requests (oven-sh/bun#40350, fixed in Bun 1.4.3).
|
|
command: `bun run --cwd ${directory}/../stories dev --port ${port} --strictPort`,
|
|
url: baseURL,
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 120_000,
|
|
// Vite reports dependency re-optimization ("optimized dependencies changed. reloading") on stdout; keep it in logs.
|
|
stdout: "pipe",
|
|
},
|
|
use: {
|
|
baseURL,
|
|
trace: "on-first-retry",
|
|
screenshot: "only-on-failure",
|
|
// CI retries failures, so the retry records the video; local runs have no retries.
|
|
video: process.env.CI ? "on-first-retry" : "retain-on-failure",
|
|
},
|
|
projects: [{ name: "components", use: { ...devices["Desktop Chrome"] } }],
|
|
})
|
|
}
|