admin管理员组

文章数量:1319488

I'm setting lighthouse ci to run in a Github action but my app is made with Gatsby and is not intended to be a PWA and when I run lhci autorun it keeps asking me to include manifest and a bunch of things related to a PWA. The only aspect I want lighthouse to check is accessibility.

This is my actual github action:

lighthouseci:
   runs-on: ubuntu-latest
   steps:
     - uses: actions/checkout@v2
     - uses: actions/setup-node@v1
     - run: yarn && sudo yarn global add @lhci/[email protected]
     - run: yarn build
     - run: lhci autorun

I'm setting lighthouse ci to run in a Github action but my app is made with Gatsby and is not intended to be a PWA and when I run lhci autorun it keeps asking me to include manifest and a bunch of things related to a PWA. The only aspect I want lighthouse to check is accessibility.

This is my actual github action:

lighthouseci:
   runs-on: ubuntu-latest
   steps:
     - uses: actions/checkout@v2
     - uses: actions/setup-node@v1
     - run: yarn && sudo yarn global add @lhci/[email protected]
     - run: yarn build
     - run: lhci autorun
Share Improve this question edited Jan 3, 2021 at 14:23 Juan Araneta asked Jan 3, 2021 at 14:17 Juan AranetaJuan Araneta 3352 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

I've just get it working, As Graham said on one reply we can disable any category we want.

{
  "ci": {
    "assert": {
      "assertions": {
        "categories:performance": "off",
        "categories:pwa": "off",
        "categories:accessibility": ["error", { "minScore": 1 }]
      }
    }
  }
}

You are looking for --only-categories as one of the flags you set.

Set the flag to only run accessibility as follows if using the mand line:

lighthouse https://example. --only-categories=accessibility

Using Github Actions

I personally don't use Github actions but from what I understand you will have to include a config file in order to run specific tests.

{
  "config": {
    "settings": {
      "onlyCategories": ["accessibility"]
    }
  }
}

Edit to include lighthouse-ci config

From what I can gather if you are using lighthouse-ci then you need to add a config file "lighthouserc.js" to the working directory with the following format:

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
    },
  },
};

本文标签: javascriptHow can I set Lighthouse CI to only test accessibilityStack Overflow