使用lighthouse-batch批量测试桌面端页面性能遇阻,--preset=desktop不生效
解决lighthouse-batch桌面端测试参数不生效的问题
用参数分隔符传递原生配置:lighthouse-batch是Lighthouse的封装工具,需用
--分隔工具自身参数与底层Lighthouse的原生参数,执行命令如下:lighthouse-batch --urls=你的URL列表文件.txt -- --preset=desktop之前直接添加
--preset=desktop会被识别为lighthouse-batch的参数而非传给Lighthouse,这是参数失效的核心原因。配置文件指定桌面预设:创建
lighthouse-desktop-config.js配置文件,内容如下:module.exports = { preset: 'desktop' };执行测试时指定该配置文件:
lighthouse-batch --urls=你的URL列表文件.txt --config-path=lighthouse-desktop-config.js强制覆盖视口参数兜底:若上述方法仍不生效,可在配置文件中直接定义桌面端视口参数,确保环境切换:
module.exports = { settings: { emulatedFormFactor: 'desktop', screenEmulation: { width: 1350, height: 940, deviceScaleFactor: 1, mobile: false } } };同样通过
--config-path指定该文件运行测试。
内容的提问来源于stack exchange,提问作者Ashutosh Jaiswal
相关产品推荐
相关产品推荐

