我正在尝试使用Node.js的spawn
命令以并行方式运行两个Cypress Docker容器。
docker run -v path/to/ws:/e2e -w /e2e --network host cypress/included:8.0.0 --spec 'cypress/integration/cytorus-cache/1.feature'
docker run -v path/to/ws:/e2e -w /e2e --network host cypress/included:8.0.0 --spec 'cypress/integration/cytorus-cache/2.feature'
它会出现以下错误:
Xvfb exited with a non zero exit code.
There was a problem spawning Xvfb.
This is likely a problem with your system, permissions, or installation of Xvfb.
----------
Error: _XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
简言之,如果我运行4个并行进程,其中1个连接到X11服务器,而3个会出现错误。
该如何处理?我已经尝试在Cypress默认运行为无头模式时设置unset DISPLAY
,但没有帮助。
--network host
导致了问题。由于主机是 AWS EC2 实例,我在运行测试时不知道机器地址。此外,应用程序可以通过一些主机名(例如localhost.example.com
)访问,因为证书已注册到*.example.com
。 - Amit Kumar Gupta-e CYPRESS_baseUrl=http://host.docker.internal:3332
和--add-host "localhost.example.com:127.0.0.1"
,但都没有起作用。我不想在 Cypress 配置中设置基本路径。Cypress 在无头模式下运行,所以我并不希望它连接 X11 服务器。有什么方法可以运行它吗? - Amit Kumar Gupta