playwright.config.live.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Playwright 线上 UI 级 E2E 配置(针对已部署站点 cfc.iwintrue.com)
  3. * ================================================================
  4. * 与 playwright.config.js 的关键区别:
  5. * - **无 globalSetup**:默认配置的 globalSetup 会执行 reset-db.sh 重置共享测试库,
  6. * 对本配置(打生产/测试已部署站点)绝对禁止。
  7. * - 只做只读浏览器自动化:不写业务数据(唯一例外是登录,属只读会话建立)。
  8. * - workers=1、fullyParallel=false:单节点串行,符合「每个节点只能跑一个浏览器自动化任务」。
  9. * - 两个 project 按 spec 分流:admin 走桌面视口,frontend(小程序 H5)走移动视口。
  10. *
  11. * 运行(单节点、串行):
  12. * npx playwright test -c playwright.config.live.js --project=admin-desktop
  13. * npx playwright test -c playwright.config.live.js --project=frontend-mobile
  14. */
  15. var path = require('path');
  16. var LIVE_BASE = process.env.LIVE_BASE_URL || 'http://cfc.iwintrue.com';
  17. module.exports = {
  18. testDir: path.join(__dirname, 'e2e-live'),
  19. timeout: 150000,
  20. expect: { timeout: 15000 },
  21. retries: 0,
  22. workers: 1,
  23. fullyParallel: false,
  24. outputDir: path.join(__dirname, '.live-artifacts'),
  25. reporter: [['list']],
  26. use: {
  27. baseURL: LIVE_BASE,
  28. headless: true,
  29. ignoreHTTPSErrors: true,
  30. actionTimeout: 20000,
  31. navigationTimeout: 60000,
  32. screenshot: 'only-on-failure',
  33. trace: 'off',
  34. video: 'off',
  35. },
  36. projects: [
  37. {
  38. name: 'admin-desktop',
  39. testMatch: /admin-live\.spec\.js$/,
  40. use: { browserName: 'chromium', viewport: { width: 1440, height: 900 } },
  41. },
  42. {
  43. name: 'frontend-mobile',
  44. testMatch: /frontend-live\.spec\.js$/,
  45. use: { browserName: 'chromium', viewport: { width: 375, height: 812 }, isMobile: true, hasTouch: true },
  46. },
  47. {
  48. // 接口级契约(商城价格排序需求变更 S1):无需浏览器,走 request fixture 直连 /api
  49. name: 'shop-api',
  50. testMatch: /shop-sort-api\.spec\.js$/,
  51. use: { browserName: 'chromium' },
  52. },
  53. {
  54. // R138:D/X 桥接鉴权契约(TC-DX-U01/U02)。此前该 spec 存在于 e2e-live 却未挂入任何
  55. // project → 设计的用例从未被执行(覆盖缺口)。端点未部署时用例按 404 记 skip,
  56. // 不产生假绿;端点上线后自动转为 401/403 断言。
  57. name: 'dx-bridge',
  58. testMatch: /dx-health-bridge-auth\.spec\.js$/,
  59. use: { browserName: 'chromium' },
  60. },
  61. ],
  62. };