New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jest-lighthouse

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-lighthouse

Helper functions to simplify Jest integration with Lighthouse

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

jest-lighthouse

CI Coverage Status npm

Helper functions to simplify Jest integration with Lighthouse

npm install -D jest-lighthouse

toHaveLighthouseAudit

expect(lhr: ).toHaveLighthouseAudit(category: string, value?: <number | Score>)

This function check if lighthouse report pass audit

Using with jest-playwright

// jest-playwright.config.js
module.exports = {
  ...
  launchType: 'LAUNCH',
  launchOptions: {
    args: ['--remote-debugging-port=9222'],
    headless: true,
  },
}

// test file
const { getLighthouseReport } = require("jest-lighthouse");

...

describe('Lighthouse', () => {
  let lhr;
  beforeAll(async () => {
    const port = 9222; // same port as defined in launchOptions
    lhr = await getLighthouseReport(url, port);
  });
  it('passes an seo audit through Lighthouse', async () => {
    expect(lhr).toHaveLighthouseAudit('seo', 90);
  });
})

...

Using with jest-puppeteer

// test file
const { getLighthouseReport } = require("jest-lighthouse");

...

describe('Lighthouse', () => {
  jest.setTimeout(15000);
  let lhr;
  beforeAll(async () => {
    const port = new URL(browser.wsEndpoint()).port;
    lhr = await getLighthouseReport(url, port);
  });
  it('passes an accessibility audit through Lighthouse', async () => {
    expect(lhr).toHaveLighthouseAudit('performance', 'perfect');
  });
})

...

Keywords

FAQs

Package last updated on 05 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc