我使用逆止器来测试我的应用程序,但它在随机测试时失败,并显示
等消息COMMAND |命令`test`在[155.109s]之后以错误结束 命令| BackstopException:ViewportNameGoesHere上的TestNameGoesHere:错误:连接ECONNREFUSED 127.0.0.1:9336
端口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
我认为问题可能发生,因为指定的端口已经在使用,但我不确定。无论如何,正如您所看到的,逆止器在此次运行中使用了从9222到9353的所有端口 - 每个测试都需要一个之前未使用过的端口。有没有办法配置逆止器重用端口?
答案 0 :(得分:1)
好像您在Windows上运行该端口时正在与另一个正在使用该端口的程序发生冲突。我唯一可以解决的建议是更改Chromy使用的默认端口,以便从适合在Linux和Windows上同时运行的点开始分配端口。
作为参考:默认情况下,Chromy从端口9222开始分配端口。
有关Chromy选项及其默认值的更多信息,请参见https://github.com/OnetapInc/chromy#chromyoptions。
您可以通过将typedef int z;
typedef int z;
typedef int z;
typedef z y;
typedef y z;
typedef float (*x[])(int, int);
typedef float (*x[])(int, int);
typedef float (*x[])(int, int);
typedef x m;
typedef m x;
添加到backstop JSON配置文件并按如下所示设置端口来设置自己的自定义“启动”端口:
engineOptions
希望这对您有所帮助!