How to use the lighthouse/lighthouse-core/report/report-generator.generateReportHtml 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 emazzotta / lighthouse-badges / __tests__ / lighthouse-badges.js View on Github external
it('should return correct metrics and a valid report', async () => {
      const expectedHtmlReport = ReportGenerator.generateReportHtml(reportFixture);
      const url = 'https://emanuelemazzotta.com';
      const shouldSaveReport = true;
      const result = await processRawLighthouseResult(
        reportFixture, url, shouldSaveReport,
      );
      expect({
        metrics: {
          'lighthouse performance': 98,
          'lighthouse pwa': 85,
          'lighthouse accessibility': 100,
          'lighthouse best-practices': 93,
          'lighthouse seo': 100,
        },
        report: {
          [url]: expectedHtmlReport,
        },
github FeliceGeracitano / webperf-dashboard / packages / lighthouse / src / utils.ts View on Github external
const saveReport = async (url: string, data: ILighthouseRespose) => {
  try {
    const report = await ReportGenerator.generateReportHtml(data);
    const site = url.replace(/(^\w+:|^)\/\//, '');
    await fs.outputFile(path.join(__dirname, '../reports', site, `LATEST.html`), report);
    return fs.outputFile(
      path.join(__dirname, '../reports', site, `${new Date().toISOString()}.html`),
      report
    );
  } catch (err) {
    console.log(`Failed to generate report for ${url} ${JSON.stringify(err)}`);
    return Promise.reject('Failed to generate report');
  }
};
github emazzotta / lighthouse-badges / src / lighthouse-badges.js View on Github external
const processRawLighthouseResult = async (data, url, shouldSaveReport) => {
  const htmlReport = shouldSaveReport ? ReportGenerator.generateReportHtml(data) : false;
  const { categories } = data;
  const scores = R.keys(categories).map((category) => (
    { [`lighthouse ${category.toLowerCase()}`]: categories[category].score * 100 }
  ));
  const lighthouseMetrics = Object.assign({}, ...scores);
  return { metrics: lighthouseMetrics, report: { [url]: htmlReport } };
};
github boyney123 / garie-lighthouse / src / light-house / utils.js View on Github external
const createReport = results => ReportGenerator.generateReportHtml(results);
github andreasonny83 / lighthouse-ci / lib / lighthouse-reporter.js View on Github external
const createHtmlReport = (results, flags) => {
  if (flags.report) {
    return ReportGenerator.generateReportHtml(results);
  }

  return null;
};