playwright.config.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { defineConfig, devices } from "@playwright/test"
  2. const port = Number(process.env.PLAYWRIGHT_PORT ?? 3000)
  3. const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? `http://127.0.0.1:${port}`
  4. const serverHost = process.env.PLAYWRIGHT_SERVER_HOST ?? "127.0.0.1"
  5. const serverPort = process.env.PLAYWRIGHT_SERVER_PORT ?? "4096"
  6. const command = `bun run dev -- --host 0.0.0.0 --port ${port}`
  7. const reuse = !process.env.CI
  8. const workers = Number(process.env.PLAYWRIGHT_WORKERS ?? (process.env.CI ? 5 : 0)) || undefined
  9. const reporter = [["html", { outputFolder: "e2e/playwright-report", open: "never" }], ["line"]] as const
  10. if (process.env.PLAYWRIGHT_JUNIT_OUTPUT) {
  11. reporter.push(["junit", { outputFile: process.env.PLAYWRIGHT_JUNIT_OUTPUT }])
  12. }
  13. export default defineConfig({
  14. testDir: "./e2e",
  15. outputDir: "./e2e/test-results",
  16. timeout: 60_000,
  17. expect: {
  18. timeout: 10_000,
  19. },
  20. fullyParallel: process.env.PLAYWRIGHT_FULLY_PARALLEL === "1",
  21. forbidOnly: !!process.env.CI,
  22. retries: process.env.CI ? 2 : 0,
  23. workers,
  24. reporter,
  25. webServer: {
  26. command,
  27. url: baseURL,
  28. reuseExistingServer: reuse,
  29. timeout: 120_000,
  30. env: {
  31. VITE_OPENCODE_SERVER_HOST: serverHost,
  32. VITE_OPENCODE_SERVER_PORT: serverPort,
  33. },
  34. },
  35. use: {
  36. baseURL,
  37. trace: "on-first-retry",
  38. screenshot: "only-on-failure",
  39. video: "retain-on-failure",
  40. },
  41. projects: [
  42. {
  43. name: "chromium",
  44. use: { ...devices["Desktop Chrome"] },
  45. },
  46. ],
  47. })