Search code examples
azure-devopsazure-pipelineslighthouse

How to define the audit score assertions for Lighthouse tests in Azure DevOps


I have the Lighthouse checks configured for some critical links on my website.

How can I integrate these checks with my build pipeline, so that it stops if any of my checks fail?


Solution

  • Once the Lighthouse checks are configured in Azure DevOps for the agreed URLs, run the Lighthouse tasks 10 - 20 times to have a good idea of the median values you should expect. Ideally, run checks for every environment you have individually, not just for the Production one.

    When you have some reference values you can start setting the audit score assertions in the “Audit score assertions” field for your Lighthouse task. Any audit score generated by Lighthouse is between 0 and 1, so that you can specify the audit score assertions that can make your pipeline fail based on the audit scores: = 1, >0, <1 etc.

    For instance, to make sure that a page has the successful HTTP status code, you should expect http-status-code = 1. Specify one assertion per line. More audit metrics of Lighthouse 5.6.0 can be found here.