ci(docs-infra): increase wait for SW on all origins to avoid CI flakes (#29988)
In #29953, the wait period for SW on localhost was increased to avoid CI flakes for the PWA score tests. This commit expands the fix to non-localhost origins to avoid flakes in the `aio_monitoring` job, when CircleCI VMs/network are slow. (For reference, example failures: [289127], [289238]) [289127]: https://circleci.com/gh/angular/angular/289127 [289238]: https://circleci.com/gh/angular/angular/289238 PR Close #29988
This commit is contained in:
parent
5650e3847b
commit
1f8325d6c4
|
@ -21,9 +21,9 @@ const logger = require('lighthouse-logger');
|
|||
// Constants
|
||||
const CHROME_LAUNCH_OPTS = {};
|
||||
const LIGHTHOUSE_FLAGS = {logLevel: 'info'};
|
||||
const LONG_WAIT_FOR_SW_DELAY = 5000;
|
||||
const SKIPPED_HTTPS_AUDITS = ['redirects-http'];
|
||||
const VIEWER_URL = 'https://googlechrome.github.io/lighthouse/viewer/';
|
||||
const WAIT_FOR_SW_DELAY = 5000;
|
||||
|
||||
// Be less verbose on CI.
|
||||
if (process.env.CI) {
|
||||
|
@ -37,8 +37,12 @@ _main(process.argv.slice(2));
|
|||
async function _main(args) {
|
||||
const {url, minScore, logFile} = parseInput(args);
|
||||
const isOnHttp = /^http:/.test(url);
|
||||
const isOnLocalhost = /\/\/localhost\b/.test(url);
|
||||
const config = {extends: 'lighthouse:default'};
|
||||
const config = {
|
||||
extends: 'lighthouse:default',
|
||||
// Since the Angular ServiceWorker waits for the app to stabilize before registering,
|
||||
// wait a few seconds after load to allow Lighthouse to reliably detect it.
|
||||
passes: [{passName: 'defaultPass', pauseAfterLoadMs: WAIT_FOR_SW_DELAY}],
|
||||
}
|
||||
|
||||
console.log(`Running PWA audit for '${url}'...`);
|
||||
|
||||
|
@ -46,10 +50,6 @@ async function _main(args) {
|
|||
// (Note: Browsers special-case localhost and run ServiceWorker even on HTTP.)
|
||||
if (isOnHttp) skipHttpsAudits(config);
|
||||
|
||||
// If testing on localhost, where the server has less optimizations (e.g. no file compression),
|
||||
// wait longer for the ServiceWorker to be registered, so Lighthouse can reliably detect it.
|
||||
if (isOnLocalhost) waitLongerForSw(config);
|
||||
|
||||
logger.setLevel(LIGHTHOUSE_FLAGS.logLevel);
|
||||
|
||||
try {
|
||||
|
@ -133,9 +133,3 @@ function skipHttpsAudits(config) {
|
|||
const settings = config.settings || (config.settings = {});
|
||||
settings.skipAudits = SKIPPED_HTTPS_AUDITS;
|
||||
}
|
||||
|
||||
function waitLongerForSw(config) {
|
||||
console.info(`Will wait longer for ServiceWorker (${LONG_WAIT_FOR_SW_DELAY}ms)...`);
|
||||
const passes = config.passes || (config.passes = []);
|
||||
passes.push({passName: 'defaultPass', pauseAfterLoadMs: LONG_WAIT_FOR_SW_DELAY});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue