How to use the lighthouse/lighthouse-core/report/report-generator.generateReport 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 Antoinebr / docker-google-lighthouse-express / app / controllers / lightouse.js View on Github external
const suffix = blockedUrlPatterns.length === 0 ? ".original" : ".blocked";

    const options = {
        blockedUrlPatterns,
        chromeFlags: ['--no-sandbox', '--headless', '--disable-gpu','--max-wait-for-load 20000']
    };


    const status = {};

    try {

        const results = await launchChromeAndRunLighthouse(url, options,budget);

        // we create the HTML 
        const html = ReportGenerator.generateReport(results.lhr, 'html')

        status.ok = true;

        // save the oupiut in process.env.REPORTS_PATH
        
        // we create the report names
        const htmlName = createReportName(url,`${suffix}.html`)
        const jsonName = createReportName(url,`${suffix}.json`);

        // Let's save the files 
        fs.writeFileSync(`${process.env.REPORTS_PATH}${jsonName}`,results.report);
        fs.writeFileSync(`${process.env.REPORTS_PATH}${htmlName}`,html);

        status.report = htmlName;
        status.reportJSON = jsonName;
github thecreazy / siteaudit / lib / audits / Lighthouse.js View on Github external
async start() {
  this.spinner = ora( `Start ${this.auditName} audit for ${this.url}` ).start();
  try {
   const results = await this.launchChromeAndRunLighthouse( this.url, this.config );
   const html = ReportGenerator.generateReport( results, 'html' );
   this.spinner.succeed( `Finish ${this.auditName} audit for ${this.url}` );
   return html;
  } catch ( e ) {
   this.spinner.fail( `Finish ${this.auditName} audit for ${this.url}` );
   return JSON.stringify( e );
  }
 }
github andreasonny83 / lighthouse-ci / lib / lighthouse-reporter.js View on Github external
const createJsonReport = (results, flags) => {
  if (flags.report && flags.jsonReport) {
    return ReportGenerator.generateReport(results, 'json');
  }

  return null;
};
github treosh / exthouse / src / index.js View on Github external
async function saveExthouseResult(ext, format, lhr) {
  const report = ReportGenerator.generateReport(lhr, format)
  const path = join(process.cwd(), `exthouse-${normalizeExtName(ext.name)}-${getFilenameDate(lhr)}.${format}`)
  await writeFile(path, report)
  if (format === formats.html) await open(path)
}