Skip to content

Instantly share code, notes, and snippets.

@joelgriffith
Last active July 8, 2017 20:38
Show Gist options
  • Save joelgriffith/8e5017ae3a9c21d250f1734ed4ecb9d3 to your computer and use it in GitHub Desktop.
Save joelgriffith/8e5017ae3a9c21d250f1734ed4ecb9d3 to your computer and use it in GitHub Desktop.
Coverage on Navalia Docs
const { Chrome } = require('navalia');
const chrome = new Chrome();
async function checkCoverageOnPage() {
// Note that we've set `coverage: true` as a 2nd parameter, this will instrument Chrome appropriately
await chrome.goto('https://joelgriffith.github.io/navalia/', { coverage: true });
await chrome.focus('#search-input');
await chrome.type('#search-input', 'coverage');
const stats = await chrome.coverage('https://www.google-analytics.com/analytics.js');
console.log(`Bytes Sent: ${stats.total}`);
console.log(`Bytes Unused : ${stats.unused}`);
console.log(`Percent Unused: ${Math.floor(stats.percentUnused * 100)}%`);
/*
Bytes Sent: 30071
Bytes Unused : 12806
Percent Unused: 42%
*/
return chrome.done();
}
checkCoverageOnPage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment