🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
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
Version published
Weekly downloads
0
-100%
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

jest

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