gpt4 book ai didi

javascript - Backstopjs 无法连接它启动的浏览器

转载 作者:可可西里 更新时间:2023-11-01 10:32:38 29 4
gpt4 key购买 nike

我正在使用 backstop 来测试我的应用程序,但它在随机测试中失败并显示类似消息

COMMAND | Command `test` ended with an error after [155.109s]
COMMAND | BackstopException: TestNameGoesHere on ViewportNameGoesHere: Error: connect ECONNREFUSED 127.0.0.1:9336

9336端口是backstop用来连接chromy的端口之一。应用端口为8082。

该问题仅在 Windows 中出现。在 Linux Mint 中一切正常。

开始测试的命令是

backstop test --configPath=backstop-config.js

配置是

module.exports = {
viewports,
scenarios,
paths: {
bitmaps_reference: `backstop-smth/bitmaps_reference`,
bitmaps_test: `backstop-smth/bitmaps_test`,
engine_scripts: `backstop/engine_scripts`,
html_report: `backstop-smth/html_report`,
ci_report: `backstop-smth/ci_report`,
},
engine: "chrome",
report: ["browser", "CLI"],
};

每个场景如下:

scenarios.push({
label,
url,
hideSelectors: ["#debug"],
removeSelectors: [],
selectors: ["body"],
readyEvent: null,
delay: 5000,
onReadyScript: null,
onBeforeScript: null,
});

这是控制台输出:

Starting Chromy: port:9222 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=954,735
Starting Chromy: port:9223 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=1024,768
Starting Chromy: port:9224 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=768,1024
Starting Chromy: port:9225 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=954,735
Starting Chromy: port:9226 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=1024,768
Starting Chromy: port:9227 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=768,1024
...
Starting Chromy: port:9336 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=954,735
Starting Chromy: port:9337 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=1024,768
Starting Chromy: port:9338 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=768,1024
Starting Chromy: port:9339 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=954,735
Starting Chromy: port:9340 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=1024,768
Starting Chromy: port:9341 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=768,1024
Starting Chromy: port:9342 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=954,735
Starting Chromy: port:9343 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=1024,768
Starting Chromy: port:9344 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=768,1024
Starting Chromy: port:9345 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=954,735
Starting Chromy: port:9346 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=1024,768
Starting Chromy: port:9347 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=768,1024
Starting Chromy: port:9348 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=954,735
Starting Chromy: port:9349 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=1024,768
Starting Chromy: port:9350 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=768,1024
Starting Chromy: port:9351 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=954,735
Starting Chromy: port:9352 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=1024,768
Starting Chromy: port:9353 --disable-gpu,--force-device-scale-factor=1,--disable-infobars=true,--window-size=768,1024
COMMAND | Command `test` ended with an error after [155.109s]
COMMAND | BackstopException: TestNameGoesHere on ViewportNameGoesHere: Error: connect ECONNREFUSED 127.0.0.1:9336

我认为可能会出现问题,因为指定的端口已在使用中,但我不确定。无论如何,如您所见,backstop 在这次运行中使用了从 9222 到 9353 的所有端口——每个测试都需要一个以前没有使用过的端口。有没有办法配置 backstop 以重用端口?

附言:Same question in Russian.

最佳答案

当您在 Windows 上运行时,您似乎正在与另一个使用该端口的程序发生冲突。我能给你解决这个问题的唯一建议是更改 Chromy 使用的默认端口,以便它从适合在 Linux 和 Windows 上运行的点开始分配端口。

供引用:默认情况下,Chromy 从端口 9222 开始分配端口。

参见 https://github.com/OnetapInc/chromy#chromyoptions有关 Chromy 选项及其默认值的更多信息。

您可以通过将 engineOptions 添加到您的 backstop JSON 配置文件并按如下方式设置端口来设置您自己的自定义“起始”端口:

"engineOptions": {
port: 9222 // Or whatever port you wish to assign
}

希望这对您有所帮助!

关于javascript - Backstopjs 无法连接它启动的浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46201755/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com