如何将 Lighthouse CI 设置为仅测试可访问性?
How can I set Lighthouse CI to only test accessibility?
我在 Github 操作中将灯塔 ci 设置为 运行,但我的应用程序是用 Gatsby 制作的,不打算成为 PWA,当我 运行 lhci autorun
它一直要求我包含清单和一堆与 PWA 相关的东西。我希望灯塔检查的唯一方面是可访问性。
这是我的实际 github 操作:
lighthouseci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: yarn && sudo yarn global add @lhci/cli@0.6.x
- run: yarn build
- run: lhci autorun
您正在寻找 --only-categories
作为您设置的标志之一。
如果使用命令行,请将标志设置为仅 运行 可访问性,如下所示:
lighthouse https://example.com --only-categories=accessibility
使用 Github 操作
我个人不使用 Github 操作,但据我了解 you will have to include a config file 是为了 运行 specific 测试。
{
"config": {
"settings": {
"onlyCategories": ["accessibility"]
}
}
}
编辑以包含 lighthouse-ci 配置
据我所知,如果您使用的是 lighthouse-ci,那么您需要将配置文件“lighthouserc.js”添加到工作目录,格式如下:
module.exports = {
ci: {
collect: {
settings: {
//set which categories you want to run here.
onlyCategories: ['accessibility']
}
},
assert: {
// assert options here
},
upload: {
// upload options here
},
server: {
// server options here
},
wizard: {
// wizard options here
},
},
};
我刚开始使用它,正如 Graham 在一个回复中所说的那样,我们可以禁用我们想要的任何类别。
{
"ci": {
"assert": {
"assertions": {
"categories:performance": "off",
"categories:pwa": "off",
"categories:accessibility": ["error", { "minScore": 1 }]
}
}
}
}
我在 Github 操作中将灯塔 ci 设置为 运行,但我的应用程序是用 Gatsby 制作的,不打算成为 PWA,当我 运行 lhci autorun
它一直要求我包含清单和一堆与 PWA 相关的东西。我希望灯塔检查的唯一方面是可访问性。
这是我的实际 github 操作:
lighthouseci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: yarn && sudo yarn global add @lhci/cli@0.6.x
- run: yarn build
- run: lhci autorun
您正在寻找 --only-categories
作为您设置的标志之一。
如果使用命令行,请将标志设置为仅 运行 可访问性,如下所示:
lighthouse https://example.com --only-categories=accessibility
使用 Github 操作
我个人不使用 Github 操作,但据我了解 you will have to include a config file 是为了 运行 specific 测试。
{
"config": {
"settings": {
"onlyCategories": ["accessibility"]
}
}
}
编辑以包含 lighthouse-ci 配置
据我所知,如果您使用的是 lighthouse-ci,那么您需要将配置文件“lighthouserc.js”添加到工作目录,格式如下:
module.exports = {
ci: {
collect: {
settings: {
//set which categories you want to run here.
onlyCategories: ['accessibility']
}
},
assert: {
// assert options here
},
upload: {
// upload options here
},
server: {
// server options here
},
wizard: {
// wizard options here
},
},
};
我刚开始使用它,正如 Graham 在一个回复中所说的那样,我们可以禁用我们想要的任何类别。
{
"ci": {
"assert": {
"assertions": {
"categories:performance": "off",
"categories:pwa": "off",
"categories:accessibility": ["error", { "minScore": 1 }]
}
}
}
}