【发布时间】:2020-10-14 13:28:16
【问题描述】:
我需要在调用lighthouse 时传递connection 参数
https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/index.js#L41
async function lighthouse(url, flags = {}, configJSON, connection) {
// verify the url is valid and that protocol is allowed
if (url && (!URL.isValid(url) || !URL.isProtocolAllowed(url))) {
throw new LHError(LHError.errors.INVALID_URL);
}
// set logging preferences, assume quiet
flags.logLevel = flags.logLevel || 'error';
log.setLevel(flags.logLevel);
const config = generateConfig(configJSON, flags);
connection = connection || new ChromeProtocol(flags.port, flags.hostname);
// kick off a lighthouse run
return Runner.run(connection, {url, config});
}
在我的 testcafe 中,我的测试看起来像
test('Run lighthouse, async t => {
lighthouse('https://www.youtube.com', {}, {}, ????)
})
我无法检索 testcafe 已打开的 chrome 实例的 connection,而不是生成新的 chromeRunner
【问题讨论】:
-
我不知道将“灯塔”与 TestCafe 集成的简单方法,需要对此进行调查。我在 TestCafe 存储库中创建了一个问题 - github.com/DevExpress/testcafe/issues/3493。跟踪它以获取有关进度的通知。
标签: google-chrome audit testcafe lighthouse