October 2017
Intermediate to advanced
302 pages
7h 27m
English
The results variable comes in as an object. It gives a detailed breakdown of each category with the score given, but we only care about trouble areas. Above our function invocation, let's add a score cutoff:
const CUTOFF = 90launchChromeAndRunLighthouse('http://localhost:5000', {}).then(results => {
We'll use this to say "only show results that score less than 90/100."
The process of logging out the results isn't too exciting, so we won't walk through it here in depth. Here's the complete file:
const serve = require('serve');const lighthouse = require('lighthouse');const chromeLauncher = require('lighthouse/chrome-launcher');function launchChromeAndRunLighthouse(url, flags = {}, config = null) { return chromeLauncher.launch().then(chrome ...Read now
Unlock full access