Has anyone used Chrome Lighthouse Node CLI to automate running audits (accessibility especially)?

Viewed 2390

Has anyone used the Node CLI version of the Google Chrome Lighthouse to automate the website auditing process? (I am most interested in the accessibility audits, but I think the question stands without that caveat).

I would like to know if there is a way to set this up to crawl entire sites, rather than just pages, and if you have done this with Lighthouse or any similar auditing application, can you share some tips or examples?

If you have not, would this be something people would be interested in as we figure it out in our organization?

3 Answers

You can use the approach suggested in this post.

You can just add more URLs in the config file to crawl all website pages. You could also extract an average value from all the test results in BigQuery to get a summary of all the website pages.

FWIW I created a Python script that will convert a Lighthouse 4 JSON audit file to a common log format and append the results to it each time it runs.

https://gist.github.com/joelhsmith/c36ad701d5d9beb598962dc62cc3d2df

  • The next part is getting it to run on a regular basis. I had it run in a Docker container for that.

  • Then analyzing the logs. We sent them to Splunk. I did that in Splunk with some success. The search queries were epic. It also allowed us to make some really sweet dashboard visualizations. Trying to do the same in Kibana now.

  • Then I set up email alerts in Splunk for when a score changes.

Hopefully that helps if anyone is looking to build on this in the future. I don't have the whole solution as good as I would like, but feel free ping me if you want more details, future human.

I think @tzam 's post would also be a cool option for some of this.

of course!

We use it to compare our web site with competitors, using a very simple nodejs application, that run analyzes then store results into elasticsearch, end we use kibana for the data-viz.

Here the code source: https://github.com/ebuildy/lighthouse-urls-bench/

lighthouse part is here https://github.com/ebuildy/lighthouse-urls-bench/blob/main/src/runnerLighthouse.mjs :

import lighthouse from 'lighthouse'
import chromeLauncher from 'chrome-launcher'

const runnerResult = await lighthouse(urlToCrawl, lhOptions, lhConfig)

// transform results, keep only valid audits
const auditsList = Object
        .values(runnerResult.lhr.audits)
        .filter(audit => {
            return typeof audit.numericValue != 'undefined'
        }).map(audit => {
            return {
                id: audit.id,
                title: audit.title,
                numericValue: audit.numericValue,
                numericUnit: audit.numericUnit,
                displayValue: audit.displayValue
            }
        })

await store({
        '@timestamp' : new Date(),
        device: {
            type: 'desktop'
        },
       url : urlToCrawl,
        auditsList
    })
Related