playwright.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Playwright E2E 测试配置
  3. *
  4. * 运行 E2E 测试前需要:
  5. * 1. 启动后端服务:cd cfc-backend && mvn spring-boot:run
  6. * 2. 启动前端 H5:cd cfc-frontend && npm run dev:h5
  7. *
  8. * 运行测试:
  9. * npx playwright test # 运行所有测试
  10. * npx playwright test tests/e2e/assessment # 运行指定测试文件
  11. * npx playwright test --grep "场景1" # 运行包含特定场景的测试
  12. */
  13. module.exports = {
  14. testDir: './e2e',
  15. timeout: 60000,
  16. retries: 0,
  17. use: {
  18. // uni-app H5 dev server (默认 8080)
  19. baseURL: 'http://localhost:8080',
  20. headless: true,
  21. viewport: { width: 375, height: 812 }, // iPhone X 尺寸
  22. ignoreHTTPSErrors: true,
  23. // 等待策略
  24. actionTimeout: 15000,
  25. navigationTimeout: 30000,
  26. },
  27. projects: [
  28. {
  29. name: 'chromium',
  30. use: { browserName: 'chromium' },
  31. },
  32. {
  33. name: 'webkit',
  34. use: { browserName: 'webkit' },
  35. },
  36. ],
  37. reporter: [
  38. ['html', { outputFolder: 'playwright-report' }],
  39. ['list'],
  40. ],
  41. // 全局测试钩子
  42. globalSetup: async () => {
  43. // 确保测试环境就绪
  44. },
  45. globalTeardown: async () => {
  46. // 清理测试数据
  47. },
  48. }