23 / 66 · 09 Mobile & Cross-Platform Testing · PWA Testing← prev⊞ allnext →☰ Read as one page
4.5Lighthouse PWA Audit in CI
# Run Lighthouse PWA audit in CI
npx lighthouse https://staging.example.com \
--only-categories=pwa \
--output=json \
--output-path=./lighthouse-pwa.json \
--chrome-flags="--headless --no-sandbox"
# Parse results and fail if score is below threshold
node -e "
const results = require('./lighthouse-pwa.json');
const score = results.categories.pwa.score * 100;
console.log('PWA Score: ' + score);
if (score < 90) {
console.error('PWA score below 90. Failing build.');
process.exit(1);
}
// Check specific audits
const audits = results.audits;
const criticalAudits = [
'service-worker',
'installable-manifest',
'splash-screen',
'themed-omnibox',
'viewport'
];
criticalAudits.forEach(audit => {
if (!audits[audit].score) {
console.error('FAILED: ' + audit + ' - ' + audits[audit].title);
process.exit(1);
}
});
"