我正在使用Backstop来测试我的应用程序,但是它在出现如下消息的随机测试中失败了
端口9336是逆止器用于连接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重用端口?
PS:Same question in Russian.
最佳答案
看起来您在Windows上运行该程序时正在与另一个正在使用该端口的程序发生冲突。我可以给您解决的唯一建议是更改Chromy使用的默认端口,以便它从适合在Linux和Windows上运行的点开始分配端口。
供引用:默认情况下,Chromy从端口9222开始分配端口。
有关Chromy选项及其默认值的更多信息,请参见https://github.com/OnetapInc/chromy#chromyoptions。
您可以通过将engineOptions
添加到backstop JSON配置文件并将端口设置如下来设置自己的自定义“启动”端口:
"engineOptions": {
port: 9222 // Or whatever port you wish to assign
}
希望这可以帮助您!
关于javascript - Backstopjs无法连接启动的浏览器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46201755/