lighthouse-aggregate-report
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

lighthouse-aggregate-report

A Google Lighthouse aggregate Test Reporter

PDF CI

Installation

npm install lighthouse-aggregate-report

Usage

More examples can be found inspecting the Tests

  1. Default Lighthouse report (performance, accessibility, pwa, best-practices, seo):

     import { lighthouseReport } from 'lighthouse-aggregate-report';
     const options = {
          url: 'https://google.com',
     };
     const results = await lighthouseReport(options);
     console.log(results)
     Output:  { performance: 50, 'accessibility': 83, pwa: 88, best-practices: 90, seo:100}
     Assertion: expect(results.performance >= 80).toBeTruthy();
  2. Only selected metrics (e.g., 'accessibility', 'pwa'):

     import { lighthouseReport, Categories } from 'lighthouse-aggregate-report';
     const options = {
          url: 'https://google.com',
          lighthouse: { 
          onlyCategories: [
              Categories.accessibility,
              Categories.pwa
          ] 
        },
     };
     const results = await lighthouseReport(options);
     console.log(results)
     Output:  { 'accessibility': 83, pwa: 88 }
     Assertion: expect(results.accessibility).to.eq(myThreshold)
  3. Selected Audit metrics:

     import { lighthouseReport, Audits } from 'lighthouse-aggregate-report';
     const options = {
          targetUrl: 'https://google.com',
          lighthouse: {
            onlyAudits: [
                Audits.firstContentfulPaint,
                Audits.interactive
            ],
         },
     };
     const results = await lighthouseReport(options);
     console.log(results)
     Output: {  performance: 97,  accessibility: 80,   pwa: 50, 'best-practices': 100,  seo: 85, interactive: 100,  'first-contentful-paint': 99 }
     Assertion: expect(results.interactive).to.eq(myThreshold)
  4. Full head (will open the browser) to troubleshoot the Login (set headed=true in the Login parameter):

     import { lighthouseReport } from 'lighthouse-aggregate-report';
     const options = {
          Login: {
              headed: true
          },
     }; 
  5. Mobile Report (set isMobile=true):

     import { lighthouseReport } from 'lighthouse-aggregate-report';
      const options = {
           isMobile: true,
           targetUrl: 'https://google.com',
      };
  6. Generate HTML Report (set htmlReport=true):

     import { lighthouseReport } from 'lighthouse-aggregate-report';
      const options = {
           htmlReport: true,
           targetUrl: 'https://google.com',
      };
  7. Debug errors (set debug=true):

     import { lighthouseReport } from 'lighthouse-aggregate-report';
     const options = {
          targetUrl: 'https://notavalidurl.com/',
          lighthouse: {
             debug: true,
          },
     };
    results = await lighthouseReport(options);
    console.log(results.error)

Contribution

Fork, add your changes and create a pull request

Package Sidebar

Install

npm i lighthouse-aggregate-report

Weekly Downloads

513

Version

1.4.1

License

Apache-2.0

Unpacked Size

36.4 kB

Total Files

11

Last publish

Collaborators

  • fasatrix