How to use the lighthouse/lighthouse-cli/run.runLighthouse 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 treosh / lighthouse-plugin-field-performance / test / mock-run.js View on Github external
;(async () => {
  try {
    sinon.stub(psi, 'runPsi').returns(Promise.resolve(data))
    await runLighthouse(
      'https://www.bbc.com/news',
      {
        output: ['html'],
        outputPath: './results/bbc.com.html',
        view: true,
        plugins: ['lighthouse-plugin-field-performance'],
        chromeFlags: '--headless'
      },
      config
    )
    process.exit(0)
  } catch (e) {
    console.log(e)
    process.exit(1)
  }
})()
github treosh / lighthouse-plugin-field-performance / test / index.js View on Github external
serial('Measure field perf for site in CruX', async t => {
  const resName = 'in-field.json'
  await runLighthouse('https://example.com/', { ...lhOptions, outputPath: `./results/${resName}` })

  const { audits, categories } = getTestResults(resName)
  checkResponse(audits['field-fcp'])
  checkResponse(audits['field-fid'])
  checkResponse(audits['field-fcp-origin'])
  checkResponse(audits['field-fid-origin'])
  t.snapshot(categories['lighthouse-plugin-field-performance'])

  /** @param {object} audit */
  function checkResponse(audit) {
    t.snapshot(omit(audit, ['details', 'displayValue', 'numericValue', 'score']))
    t.true(isNumber(audit.score) && audit.score > 0 && audit.score < 1)
    t.true(isNumber(audit.numericValue))
    t.true(isString(audit.displayValue))
    t.snapshot({
      ...audit.details,
github treosh / lighthouse-plugin-field-performance / test / index.js View on Github external
serial('Measure field perf for site site not in CruX', async t => {
  const resName = 'not-in-field.json'
  await runLighthouse('https://alekseykulikov.com/', { ...lhOptions, outputPath: `./results/${resName}` })

  const { audits, categories } = getTestResults(resName)
  t.snapshot(audits['field-fcp'])
  t.snapshot(audits['field-fid'])
  t.snapshot(audits['field-fcp-origin'])
  t.snapshot(audits['field-fid-origin'])
  t.snapshot(categories['lighthouse-plugin-field-performance'])
})
github thegreenwebfoundation / lighthouse-plugin-greenhouse / check-domain.js View on Github external
const { runLighthouse } = require('lighthouse/lighthouse-cli/run')

const lhOptions = {
  output: ['json'],
  outputPath: './results/test-results.json',
  chromeFlags: '--headless --enable-logging --no-sandbox',
  plugins: ['lighthouse-plugin-greenhouse']
}

runLighthouse('https://www.google.com', lhOptions).then(result => {
  process.exit(0);
})