Skip to content

Commit

Permalink
Easy serviceworker testing config. To run:
Browse files Browse the repository at this point in the history
    yarn sw -- http://caltrainschedule.io --output=json
  • Loading branch information
paulirish committed Mar 14, 2017
1 parent ade2d88 commit 52f42e4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -21,3 +21,4 @@ lighthouse-cli/types/*.js
# Handlebar-templates
lighthouse-core/report/templates/report-templates.js
lighthouse-core/report/partials/templates/report-partials.js
lighthouse-core/formatters/partials/templates/report-partials.js
9 changes: 8 additions & 1 deletion lighthouse-core/audits/service-worker.js
Expand Up @@ -20,6 +20,8 @@
const URL = require('../lib/url-shim');
const Audit = require('./audit');

const Formatter = require('../report/formatter');

/**
* @param {!Array<!ServiceWorkerVersion>} versions
* @param {string} url
Expand Down Expand Up @@ -56,8 +58,13 @@ class ServiceWorker extends Audit {
const version = getActivatedServiceWorker(
artifacts.ServiceWorker.versions, artifacts.URL.finalUrl);


return {
rawValue: !!version
rawValue: !!version,
extendedInfo: {
formatter: Formatter.SUPPORTED_FORMATS.NULL,
value: artifacts.ServiceWorker.versions
}
};
}
}
Expand Down
44 changes: 44 additions & 0 deletions lighthouse-core/config/sw.json
@@ -0,0 +1,44 @@
{
"passes": [{
"passName": "defaultPass",
"recordNetwork": true,
"useThrottling": false,
"gatherers": [
"url"
]
},
{
"passName": "offlinePass",
"recordNetwork": true,
"useThrottling": false,
"gatherers": [
"service-worker",
"offline"
]
}
],

"audits": [
"service-worker",
"works-offline"
],

"aggregations": [{
"name": "Service Worker State",
"description": "",
"scored": false,
"categorizable": false,
"items": [{
"audits": {
"service-worker": {
"expectedValue": true,
"weight": 1
},
"works-offline": {
"expectedValue": true,
"weight": 1
}
}
}]
}]
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -33,6 +33,7 @@
"watch": "bash lighthouse-core/scripts/run-mocha.sh --watch",
"chrome": "node ./lighthouse-cli/manual-chrome-launcher.js",
"fast": "npm run start -- --disable-device-emulation --disable-cpu-throttling --disable-network-throttling",
"sw": "npm run start -- --disable-cpu-throttling --disable-network-throttling --config-path=./lighthouse-core/config/sw.json",
"smokehouse": "node lighthouse-cli/test/smokehouse/smokehouse.js",
"deploy-viewer": "cd lighthouse-viewer && gulp deploy"
},
Expand Down

0 comments on commit 52f42e4

Please sign in to comment.