playwright.config.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 =
  9. Number(process.env.PLAYWRIGHT_WORKERS ?? (process.env.CI ? (process.platform === "win32" ? 2 : 5) : 0)) || undefined
  10. export default defineConfig({
  11. testDir: "./e2e",
  12. outputDir: "./e2e/test-results",
  13. timeout: 60_000,
  14. expect: {
  15. timeout: 10_000,
  16. },
  17. fullyParallel: process.env.PLAYWRIGHT_FULLY_PARALLEL === "1",
  18. forbidOnly: !!process.env.CI,
  19. retries: process.env.CI ? 2 : 0,
  20. workers,
  21. reporter: [["html", { outputFolder: "e2e/playwright-report", open: "never" }], ["line"]],
  22. webServer: {
  23. command,
  24. url: baseURL,
  25. reuseExistingServer: reuse,
  26. timeout: 120_000,
  27. env: {
  28. VITE_OPENCODE_SERVER_HOST: serverHost,
  29. VITE_OPENCODE_SERVER_PORT: serverPort,
  30. },
  31. },
  32. use: {
  33. baseURL,
  34. trace: "on-first-retry",
  35. screenshot: "only-on-failure",
  36. video: "retain-on-failure",
  37. },
  38. projects: [
  39. {
  40. name: "chromium",
  41. use: { ...devices["Desktop Chrome"] },
  42. },
  43. ],
  44. })