javascript 在WSL上运行Cypress

ltskdhd1  于 2023-10-14  发布在  Java
关注(0)|答案(5)|浏览(112)

我试图在Ubuntu的WSL上运行cypress,这是我得到的:

$ cypress run
[29023:1018/155130.159647:ERROR:bus.cc(392)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[29023:1018/155130.162020:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[29023:1018/155130.162068:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[29211:1018/155130.193707:ERROR:gpu_init.cc(441)] Passthrough is not supported, GL is swiftshader

...

[29023:1018/155132.292604:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

Timed out waiting for the browser to connect. Retrying...
[29023:1018/155232.249036:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

Timed out waiting for the browser to connect. Retrying again...
[29023:1018/155332.249372:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
 (-2) loading 'http://localhost:3000/__/#/tests/integration/simple.spec.ts'
Error:  (-2) loading 'http://localhost:3000/__/#/tests/integration/simple.spec.ts'
    at rejectAndCleanup (electron/js2c/browser_init.js:161:7486)
    at Object.failListener (electron/js2c/browser_init.js:161:7699)
    at Object.emit (events.js:376:20)

我找不到任何相关的主题,有帮助吗?

lzfw57am

lzfw57am1#

Cypress需要能够运行其GUI。根据您的Windows版本,您可能需要一些额外的配置才能在WSL中运行GUI应用程序:

  • 对于所有Windows版本,请确保安装所需的依赖项:
apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb

这可能已经为您完成,具体取决于您如何安装Cypress。我在Cypress文档中使用了npm directions

  • Windows 11默认包含WSLg功能,允许您直接在Windows上运行GUI应用程序。如果您从Windows 10升级到Windows 11,请运行wsl --update以确保您拥有最新的WSL版本和WSLg。

另外,如果您试图在旧版本上运行X服务器(如下一个建议),请确保您在启动文件中删除了DISPLAY的任何手动配置(例如:~/.bashrc等)。

  • 对于Windows 10,您需要进行一些额外的配置。实际上有两种方法可以做到这一点,但这是一个更好的超级用户的主题(因为它与编程没有直接关系),所以我将向您指出this Super User question的一些细节。两个答案都可以。虽然我偏爱我的解决方案,但大多数人选择运行第三方X服务器,就像harrymc在那里的回答一样。

只是为了确保没有任何“隐藏的技巧”需要让Cypress运行,我可以确认,我能够成功地使用Cypress instructions和我的xrdp技术从超级用户的答案./node_modules/.bin/cypress open

jhdbpxl9

jhdbpxl92#

这个错误也开始在我们的Azure Cypress管道中弹出。然而,当我们迁移到Cypress 8.6.0时,它开始发生,这是Cypress的最新版本。回到8.4.0解决了我们的问题。

ctehm74n

ctehm74n3#

我在看各种帖子时运气不好,有时在VPN后面,公司防火墙似乎是一个主要问题。
我经常会遇到这样的错误:

[14874:0408/102328.150664:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[14874:0408/102328.150745:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[15032:0408/102328.255402:ERROR:gpu_init.cc(453)] Passthrough is not supported, GL is swiftshader, ANGLE is
[14874:0408/102328.321306:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[14874:0408/102328.331513:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[14874:0408/102402.013363:ERROR:connection.cc(66)] X connection error received.
[15032:0408/102402.014034:ERROR:connection.cc(66)] X connection error received.
[15032:0408/102402.014064:ERROR:connection.cc(66)] X connection error received.

我发现问题是WSL 2需要将显示器设置为主机Windows机器的IP地址。这听起来很奇怪,但如果您不熟悉WSL 2,它有自己的IP地址和子网;因此,您需要告诉它使用不是自己的显示器的IP。
我在这里记录了整个过程:https://gist.github.com/pjobson/6b9fb926c59f58aa73d4efa10fe13654
我的步骤是:
1.安装依赖项
1.为我的公司防火墙安装证书
1.安装节点
1.安装vcxsrv
1.设置$$
1.设置DBUS
1.启动X-Server
1.编辑Windows防火墙
1.安装Cypress

flseospp

flseospp4#

Cypress故障排除页面指示您可以忽略这些错误。我现在不确定这是错误还是红鲱鱼。
https://docs.cypress.io/guides/references/troubleshooting#Run-the-Cypress-app-by-itself
注意:详细的Electron日志记录可能会显示警告,但仍允许Cypress正常工作。例如,Cypress Test Runner正常打开,尽管下面的输出很吓人:[475:0617/150421.326986:ERROR:bus.cc(395)] Failed to connect to the bus:无法连接到套接字/var/run/dbus/system_bus_socket:没有这样的文件或目录[475:0617/150425.061526:ERROR:bus.cc(395)]无法连接到总线:无法分析服务器地址:未知的地址类型(有效类型的示例为“tcp”,在UNIX上为“unix”)[475:0617/150425.079819:ERROR:bus.cc(395)]无法连接到总线:无法分析服务器地址:未知的地址类型(有效类型的示例为“tcp”,在UNIX上为“unix”)
我有这个错误的超时柏树运行,但也成功运行。这让我相信我可以忽略它。

lsmd5eda

lsmd5eda5#

我今天面临这个错误,更新柏树修复了我的错误
npm install cypress@latest

相关问题