playwright.config.api.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Playwright API 级测试配置(远程后端)
  3. * ================================================================
  4. * 用途:针对远程后端 API(http://cfc.iwintrue.com)运行「API 级 e2e」。
  5. * 特点:
  6. * - 无 globalSetup(绝不重置远程数据库)
  7. * - 独立 outputDir(.api-artifacts):API 用例不产出截图/trace,
  8. * 避免累积大量产物触发本地 safe-delete 批量守卫,导致运行前被中断
  9. * - 仅 list reporter,不生成 html 报告目录
  10. * - 用例通过 request fixture 直连 /api/*,不依赖前端 SPA
  11. *
  12. * 运行:npx playwright test <spec> -c playwright.config.api.js --project=desktop
  13. */
  14. var path = require('path');
  15. module.exports = {
  16. testDir: path.join(__dirname, 'e2e'),
  17. testMatch: /api[\\/].*\.spec\.js$/,
  18. // 远程接口冷启动较慢(/api/family/member/add 首调实测约 16s),单用例含多次调用,放宽用例级超时
  19. timeout: 180000,
  20. retries: 0,
  21. workers: 1,
  22. outputDir: path.join(__dirname, '.api-artifacts'),
  23. reporter: [['list']],
  24. use: {
  25. // 默认远端;本地复验时用 CFC_API_BASE 指向已启动的 cfc-backend(如 http://127.0.0.1:9082)
  26. baseURL: process.env.CFC_API_BASE || 'http://cfc.iwintrue.com',
  27. headless: true,
  28. ignoreHTTPSErrors: true,
  29. actionTimeout: 15000,
  30. navigationTimeout: 60000,
  31. screenshot: 'off',
  32. trace: 'off',
  33. video: 'off',
  34. },
  35. projects: [
  36. {
  37. name: 'desktop',
  38. use: {
  39. browserName: 'chromium',
  40. viewport: { width: 1440, height: 900 },
  41. },
  42. },
  43. ],
  44. };