playwright.config.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { defineConfig, devices } from '@playwright/test';
  2. export default defineConfig({
  3. testDir: '.',
  4. fullyParallel: true,
  5. forbidOnly: !!process.env.CI,
  6. retries: process.env.CI ? 2 : 0,
  7. workers: process.env.CI ? 1 : undefined,
  8. timeout: 60000, // 增加全局超时时间到60秒
  9. expect: {
  10. timeout: 15000, // 增加expect超时时间
  11. },
  12. reporter: [
  13. ['html'],
  14. ['list'],
  15. ['junit', { outputFile: 'test-results/junit.xml' }]
  16. ],
  17. use: {
  18. baseURL: process.env.E2E_BASE_URL || 'http://localhost:8080',
  19. trace: 'on-first-retry',
  20. screenshot: 'only-on-failure',
  21. video: 'retain-on-failure',
  22. actionTimeout: 15000, // 增加操作超时时间
  23. navigationTimeout: 30000, // 增加导航超时时间
  24. },
  25. projects: [
  26. {
  27. name: 'chromium',
  28. use: { ...devices['Desktop Chrome'] },
  29. },
  30. {
  31. name: 'firefox',
  32. use: { ...devices['Desktop Firefox'] },
  33. },
  34. {
  35. name: 'webkit',
  36. use: { ...devices['Desktop Safari'] },
  37. },
  38. {
  39. name: 'Mobile Chrome',
  40. use: { ...devices['Pixel 5'] },
  41. },
  42. {
  43. name: 'Mobile Safari',
  44. use: { ...devices['iPhone 12'] },
  45. },
  46. ],
  47. webServer: {
  48. command: 'npm run dev',
  49. url: 'http://localhost:8080',
  50. reuseExistingServer: !process.env.CI,
  51. timeout: 120000,
  52. },
  53. });