playwright.config.api.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. baseURL: 'http://cfc.iwintrue.com',
  26. headless: true,
  27. ignoreHTTPSErrors: true,
  28. actionTimeout: 15000,
  29. navigationTimeout: 60000,
  30. screenshot: 'off',
  31. trace: 'off',
  32. video: 'off',
  33. },
  34. projects: [
  35. {
  36. name: 'desktop',
  37. use: {
  38. browserName: 'chromium',
  39. viewport: { width: 1440, height: 900 },
  40. },
  41. },
  42. ],
  43. };