【问题标题】:WebSocket error when using Playwright on GitLab CI在 GitLab CI 上使用 Playwright 时出现 WebSocket 错误
【发布时间】:2020-10-17 12:36:43
【问题描述】:

我正在使用带有 Jest 和 jest-playwright-preset 的 Playwright,并试图让我的测试在 GitLab CI 中运行。

我的 .gitlab-ci.yml:

ui_test:
  image: node:latest
  script:
    - npm install
    - npm run test:ui

当我在我的 Windows 机器上本地运行它时,一切正常。但是,如果我尝试在 GitLab CI 中运行,则会收到以下错误:

 2020-06-26T21:01:39.770Z pw:api => chromium.launchServer started
 2020-06-26T21:01:39.786Z pw:api <= chromium.launchServer succeeded
 2020-06-26T21:01:40.182Z pw:api => chromium.connect started
 2020-06-26T21:01:40.217Z pw:api <= chromium.connect failed
 FAIL browser: chromium ./test.js
   ● Test suite failed to run
     WebSocket error: connect ECONNRESET 127.0.0.1:38267
     ================== chromium.connect logs ==================
     <ws connecting> ws://127.0.0.1:38267/b32ed779b7c87222e0b2b6aa117b0c79
     <ws connect error> ws://127.0.0.1:38267/b32ed779b7c87222e0b2b6aa117b0c79 connect ECONNRESET 127.0.0.1:38267
     <ws disconnected> ws://127.0.0.1:38267/b32ed779b7c87222e0b2b6aa117b0c79
     ============================================================
     Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
       at WebSocket.<anonymous> (node_modules/playwright/lib/transport.js:119:24)
       at WebSocket.onError (node_modules/playwright/node_modules/ws/lib/event-target.js:128:16)
       at ClientRequest.<anonymous> (node_modules/playwright/node_modules/ws/lib/websocket.js:568:15)

编辑:这与 Jest 无关。仅使用 Playwright 并使用节点图像而不是 Playwright 图像时会出现同样的问题。

【问题讨论】:

    标签: jestjs gitlab-ci playwright


    【解决方案1】:

    node:latest 没有适当的系统依赖项来运行浏览器。您可以使用Playwright docker image

    ui-test:
      stage: test
      image: mcr.microsoft.com/playwright:bionic
      script:
        - npm install # this should install playwright
        - npm run test:ui
    

    (已编辑以反映官方 docker 图像)

    【讨论】:

      猜你喜欢
      • 2020-04-26
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 2022-01-05
      • 1970-01-01
      • 2021-11-10
      • 2021-07-24
      • 1970-01-01
      相关资源
      最近更新 更多