我正在尝试执行与该灯塔命令相同的操作,但是我不知道怎么做。
-O3
关于如何以编程方式为灯塔设置自定义配置文件(带有自定义收集器和审核),是否有人可以分享示例?
答案 0 :(得分:0)
我设法自己找到了答案,所以我将其发布在下面:
// This how I call lighthouse programmatically
const lhr = await lighthouse(url, config.lighthouseFlags, config.lighthouseConfigs);
var url = "https://www.example.com";
var config = {};
// The 2nd parameter in the lighthouse function is some of the flags you can pass to lighthouse. I'm posting a few examples below:
conig.lighthouseFlags = {
"output": [
"html"
],
"emulatedFormFactor": "none",
"disableStorageReset": "true",
"disableDeviceEmulation": "true"
};
// The 3rd parameter includes the configuration on how to run the tests in lighthouse
conig.lighthouseConfigs = {
"extends": "lighthouse:default",
"passes": [{
"passName": "defaultPass",
"gatherers": [
"gatherer_more_seo"
]
}],
"audits": [
"audit_seo_something"
],
"categories": {
"more_seo": {
"title": "Friendly title",
"description": "Friendly description",
"auditRefs": [{
"id": "more-seo-field",
"weight": 1
}]
}
}
};