How to use the lighthouse function in lighthouse

To help you get started, we’ve selected a few lighthouse 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 ModusCreateOrg / gimbal / packages / gimbal / src / module / lighthouse / index.ts View on Github external
if (!config.outputHtml) {
      /* eslint-disable-next-line no-param-reassign  */
      config.outputHtml = commandOptions.lighthouseOutputHtml as string;
    }
  }

  const auditStartEvent: AuditStartEvent = {
    config,
    options,
    url,
  };

  await EventEmitter.fire(`module/lighthouse/audit/start`, auditStartEvent);

  const audit: Audit = await lighthouse(
    url,
    {
      ...options,
      port: options.chromePort,
    },
    config,
  );

  const auditEndEvent: AuditEndEvent = {
    audit,
    config,
    options,
    url,
  };

  await EventEmitter.fire(`module/lighthouse/audit/end`, auditEndEvent);
github ModusCreateOrg / gimbal / packages / gimbal / src / module / lighthouse / index.ts View on Github external
if (!config.outputHtml) {
      /* eslint-disable-next-line no-param-reassign  */
      config.outputHtml = commandOptions.lighthouseOutputHtml as string;
    }
  }

  const auditStartEvent: AuditStartEvent = {
    config,
    options,
    url,
  };

  await EventEmitter.fire(`module/lighthouse/audit/start`, auditStartEvent);

  const audit: Audit = await lighthouse(
    url,
    {
      ...options,
      port: options.chromePort,
    },
    config,
  );

  const auditEndEvent: AuditEndEvent = {
    audit,
    config,
    options,
    url,
  };

  await EventEmitter.fire(`module/lighthouse/audit/end`, auditEndEvent);
github sevenwestmedia / project-watchtower / lib / stats / lighthouse.ts View on Github external
export const runLighthouse = async (log: Logger, url: string) => {
    try {
        log.debug({ url }, 'Running lighthouse')
        const results = await lighthouse(
            url,
            {
                output: 'json',
                // provided by build environment, ref OPS-383
                port: Number(process.env.CHROME_REMOTE_DEBUGGING_PORT) || 9222,
                skipAutolaunch: true,
            },
            {
                extends: 'lighthouse:default',
                settings: {},
            },
        )

        return results
    } catch (err) {
        log.error({ err }, 'Could not run lighthouse!')
github csabapalfi / pagespeed-score / local / index.js View on Github external
export default async function test(
  url, 
  config = getConfig(), 
  {chromeFlags, ...options} = getOptions(),
) {
  const chrome = await launch({chromeFlags});
  const {lhr: result} = 
  await lighthouse(url, {port: chrome.port, ...options}, config);
  await chrome.kill();
  return result;
}
github luke-j / lighthouse-thresholds / index.js View on Github external
const launchChromeAndRunLighthouse = async url => {
  try {
    log(`fetching ${url}`)
    const chromeFlags = ['--headless', '--no-sandbox', '--disable-gpu']
    const chrome = await chromeLauncher.launch({
      chromeFlags,
      connectionPollInterval: 10000
    })
    log('running lighthouse')
    const results = await lighthouse(
      url,
      { chromeFlags, port: chrome.port },
      null
    )

    delete results.artifacts
    await chrome.kill()

    return results
  } catch (e) {
    throw e
  }
}
github YoshiyukiKato / nightharbor / src / runner / exec-lighthouse.ts View on Github external
const works = browsers.map((browser, index) => {
          const target = targets[index];
          const port = new URL(browser.wsEndpoint()).port;
          const opts: any = {port};
          return lighthouse(target.url, opts, lighthouseConfig)
            .then((result: any) => {
              context.addReport(target, result);
              return browser.close();
            });
        });