Abhinaba Ghosh

Nov 11, 2019

4 min read

Measure your website’s performance with Google Lighthouse in Automated pipelines

Ever Thought About It?

Note

Here it is — Google Lighthouse

  1. Use Lighthouse as command-line execution
  2. Use Lighthouse in integration with Test Automation Tool

Lighthouse Protractor Integration

You can find the Github project here.

npm install

Tweak Protractor Configuration

  • Set the remote debugging port of protractor to 4444.
  • Turn Off “directConnect : true”

Create Lighthouse Expectation File

{"accessibilityScore": 90,"performanceScore": 75,"bestPracticeScore": 75,"progressiveWebAppScore": 75}

Lighthouse Helper Methods

  • Perform lighthouse Audit
  • Fetch run time lighthouse scores of different segments
  • Assert the run time score with the expected data
  • Generate HTML report
const opts = {logLevel: "info",output: "json",port: 4444};
const lhr = await lighthouse(url, opts);

Create Your Specs Files

Lighthouse Protractor Runner

Parking Lot