azure-devopssitecorelighthouseazure-devops-extensionsazure-devops-pipelines

How to filter out the unwanted information / checks from Lighthouse Azure DevOps report produced for a Sitecore site hosted in Azure PaaS?


I am working on the quality improvements of my Sitecore website deployed into Azure PaaS and use Lighthouse as Azure DevOps extension for Azure Pipelines to run a Lighthouse report from time to time to check scores.

This is how a standard Lighhouse report looks like by default - the full information about all sections:

Standard Lighthouse report

Ideally, I would like to run checks against the most relevant categories and individual criteria inside, and get results only for the sections and metrics I am interested in. This will help me to avoid the information clutter and considerably reduce the test duration time. For instance, my site doesn’t currently meet the Progressive Web App (PWA) requirements, therefore, I want to exclude the PWA category & checks from the Lighthouse report completely. Also, it would help to make the Accessibility section optional as I don't do much changes in that regard.

Could you please advise me on the best approach?


Solution

  • Filtering can be done by using CLI arguments for the Lighthouse DevOps task as follows:

    CLI arguments

    To ignore PWA checks, use "preset": "lighthouse:no-pwa" preset in your lighthouserc.json config file. I would also recommend that you specify your desired baselines for warnings. For example, to assert performance, accessibility, best-practices and SEO categories against a baseline score of 0.70, use the following configuration:

    { 
        "assert": {  
            "preset": "lighthouse:no-pwa",  
            "assertions": {  
                "categories:performance": ["warn", {"aggregationMethod": "optimistic", "minScore": 0.70}],  
                "categories:accessibility": ["warn", {"aggregationMethod": "optimistic", "minScore": 0.70}],  
                "categories:best-practices": ["warn", {"aggregationMethod": "optimistic", "minScore": 0.70}],  
                "categories:seo": ["warn", {"aggregationMethod": "optimistic", "minScore": 0.70}]
            }
        }  
    } 
    

    Where required, the individual items with a certain category can be audited, for example, "first-contentful-paint": "off" or "uses-responsive-images": ["error", {"maxLength": 0}]. For a reference of the audit IDs in each category, see the default Lighthouse config. When no options are set, the default options of {"aggregationMethod": "optimistic", "minScore": 1} are used.