How to use the chrome-launcher/chrome-launcher.launch function in chrome-launcher

To help you get started, we’ve selected a few chrome-launcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marclaval / optimize-angular-app / scripts / lighthouse.js View on Github external
function getPerf(scenario) {
  const url = 'http://localhost:8080/' + scenario;
  let launchedChrome = null
  return ChromeLauncher.launch({port: 9222})
    .then((chrome) => {
      launchedChrome = chrome;
      const lhOpts = {mobile: true, loadPage: true};
      return lighthouse(url, lhOpts, perfConfig)
        .then(res => {
          report = res;
          delete report.audits['screenshot-thumbnails'];
          delete report.reportCategories;
          delete report.reportGroups;
        });
    })
    .then(() => {
      if (launchedChrome) {
        launchedChrome.kill();
      }
    })