playwright.config.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /// <reference types="node" />
  2. import { defineConfig, devices } from '@playwright/test'
  3. const PORT = Number(process.env.PLAYWRIGHT_PORT || 4173)
  4. const BASE_URL = `http://127.0.0.1:${PORT}`
  5. // Allow environments without managed Playwright Chromium to use a local browser.
  6. // Example: PLAYWRIGHT_CHANNEL=chrome npx playwright test
  7. const BROWSER_CHANNEL = process.env.PLAYWRIGHT_CHANNEL as 'chrome' | 'msedge' | undefined
  8. export default defineConfig({
  9. testDir: './tests/e2e',
  10. fullyParallel: true,
  11. forbidOnly: !!process.env.CI,
  12. retries: process.env.CI ? 2 : 0,
  13. workers: process.env.CI ? 1 : undefined,
  14. reporter: process.env.CI ? [['dot'], ['html', { open: 'never' }]] : [['list']],
  15. use: {
  16. baseURL: BASE_URL,
  17. locale: 'en-US',
  18. trace: 'retain-on-failure',
  19. screenshot: 'only-on-failure',
  20. // Managed ffmpeg is not always available when using a system browser channel.
  21. video: BROWSER_CHANNEL ? 'off' : 'retain-on-failure',
  22. },
  23. webServer: {
  24. command: `npx vite --host 127.0.0.1 --port ${PORT}`,
  25. url: BASE_URL,
  26. reuseExistingServer: !process.env.CI,
  27. timeout: 120_000,
  28. },
  29. projects: [
  30. {
  31. name: 'chromium',
  32. use: {
  33. ...devices['Desktop Chrome'],
  34. ...(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {}),
  35. },
  36. },
  37. ],
  38. })
粤ICP备19079148号