Reputation: 2716
I would like to run a Lighthouse audit behind an authentication wall. For example, below I tried to run Lighthouse using PageSpeed Insights to a URL that usually resolves to my Gmail account. However, as seen below, the Lighthouse audit ran against the sign in page, not my Gmail.
Therefore, how can I run Lighthouse programmatically behind an authentication wall? I understand that I can log in to a page, navigate to the DevTools -> Audits page, and manually run an audit; however, I would like to figure out a way to do this programmatically (via PageSpeed Insights API call or via DevTools in a programmatic way is best, but via NodeJS is OK too).
Upvotes: 4
Views: 2880
Reputation: 24865
You cannot do this 'out of the box' with just lighthouse.
google-lighthouse-puppeteer however allows you to use puppeteer to handle the login first and then run lighthouse.
It is a steep learning curve but once you master puppeteer it opens up lots of automated testing capabilities.
Upvotes: 2
Reputation: 2895
There seems to be a NPM distribution for Lightouse:
https://www.npmjs.com/package/lighthouse
Following the examples you should be able to use it with something like this:
lighthouse --output html --output-path ./report.html
Upvotes: -2