diff --git a/aio/package.json b/aio/package.json index 7e88ae6e25..2f8e52f70f 100644 --- a/aio/package.json +++ b/aio/package.json @@ -121,7 +121,7 @@ "karma-coverage-istanbul-reporter": "^1.3.0", "karma-jasmine": "^1.1.0", "karma-jasmine-html-reporter": "^0.2.2", - "lighthouse": "^2.1.0", + "lighthouse": "^2.5.0", "lodash": "^4.17.4", "lunr": "^2.1.0", "protractor": "~5.1.0", diff --git a/aio/scripts/test-pwa-score.js b/aio/scripts/test-pwa-score.js index 388d76651d..d41db50d0e 100644 --- a/aio/scripts/test-pwa-score.js +++ b/aio/scripts/test-pwa-score.js @@ -7,12 +7,12 @@ * Fails if the score is below ``. * If `` is defined, the full results will be logged there. * - * (Ignores HTTPS-related audits, when run for HTTP URL.) + * (Skips HTTPS-related audits, when run for HTTP URL.) */ // Imports const lighthouse = require('lighthouse'); -const chromeLauncher = require('lighthouse/chrome-launcher/chrome-launcher'); +const chromeLauncher = require('lighthouse/chrome-launcher'); const printer = require('lighthouse/lighthouse-cli/printer'); const config = require('lighthouse/lighthouse-core/config/default.js'); @@ -35,7 +35,7 @@ function _main(args) { console.log(`Running PWA audit for '${url}'...`); if (isOnHttp) { - ignoreHttpsAudits(config); + skipHttpsAudits(config); } launchChromeAndRunLighthouse(url, {}, config). @@ -54,20 +54,14 @@ function evaluateScore(expectedScore, actualScore) { } } -function ignoreHttpsAudits(config) { +function skipHttpsAudits(config) { const httpsAudits = [ 'redirects-http' ]; - console.info(`Ignoring HTTPS-related audits (${httpsAudits.join(', ')})...`); + console.info(`Skipping HTTPS-related audits (${httpsAudits.join(', ')})...`); - config.categories.pwa.audits.forEach(audit => { - if (httpsAudits.indexOf(audit.id) !== -1) { - // Ugly hack to ignore HTTPS-related audits. - // Only meant for use during development. - audit.weight = 0; - } - }); + config.settings.skipAudits = httpsAudits; } function launchChromeAndRunLighthouse(url, flags, config) { @@ -105,7 +99,10 @@ function processResults(results, logFile) { console.log(`Saving results in '${logFile}'...`); console.log(`(LightHouse viewer: ${VIEWER_URL})`); - results.artifacts = undefined; // Too large for the logs. + // Remove the artifacts, which are not necessary for the report. + // (Saves ~1,500,000 lines of formatted JSON output \o/) + results.artifacts = undefined; + promise = printer.write(results, 'json', logFile); } diff --git a/aio/yarn.lock b/aio/yarn.lock index 560e44d181..23d84dc2aa 100644 --- a/aio/yarn.lock +++ b/aio/yarn.lock @@ -4998,7 +4998,7 @@ lighthouse-logger@^1.0.0: dependencies: debug "^2.6.8" -lighthouse@^2.1.0: +lighthouse@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/lighthouse/-/lighthouse-2.5.0.tgz#c38c3bb0cfc5645bd59ed2550531bdc59a6c8fdd" dependencies: