在 GitLab CI 上使用 Playwright 时出现 WebSocket 错误



我正在使用带有 Jest 和 jest-playwright 预设的 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)

编辑:这与开玩笑无关。当仅使用剧作家并使用节点图像而不是剧作家图像时,会出现同样的问题。

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

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

(编辑以反映官方码头工人形象(

最新更新