You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 17:17:02