npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

codeceptjs-lighthouse-helper

v1.1.1

Published

Lighthouse Audit Helper for codeceptjs

Downloads

54

Readme

"Buy Me A Coffee"

codeceptjs-lighthouse-helper

CodeceptJS Lighthouse helper wraps lighthouse audit using playwright to perform audit check against your web application.

NPM package: https://www.npmjs.com/package/codeceptjs-lighthouse-helper

Installation

npm i codeceptjs-lighthouse-helper --save-dev

Configuration

This helper should be added in your codeceptjs config file: codecept.conf.*

Example:

{
...
   helpers: {
     LighthouseHelper: {
      require: 'codeceptjs-lighthouse-helper',
    }
   }
...
}

Usage

  • To use this helper, you must enable Playwright helper.
  • After install the helper, you can use it by calling I.runPerformanceCheck()
  • If there is auto-complete for I actor, try running npx codeceptjs def

Options

By default, this setting is enabled:

  • thresholds: { performance: 10, accessibility: 30, 'best-practices': 30, seo: 30, pwa: 30, }
  • htmlReport: true
  • outputDir: 'output',
  • reportFileName: 'accessibility-audit.html',
  • port: 9222

More info could be found here

Feature("Performance Check with Lighthouse")
	.config({
		chromium: {
			args: [`--remote-debugging-port=9222`],
		},
	})
Scenario("Performance check", async () => {
	I.amOnPage("https://js.devexpress.com/Demos/WidgetsGallery/Demo/Slider/Overview/jQuery/Light/");
	await I.runPerformanceCheck({ reportFileName: 'customname' });
});

Output

CodeceptJS v3.4.1 #StandWithUkraine
Using test root "/Users/thanh.nguyen/Desktop/codeceptjs-lighthouse-helper/test"
Helpers: Playwright, LighthouseHelper
Plugins: screenshotOnFail, allure

Performance Check with Lighthouse --
    [1]  Starting recording promises
 › [Suite Config] Playwright {"chromium":{"args":["--remote-debugging-port=9222"]}}
    Timeouts: 
 › [Session] Starting singleton browser session
  Performance check
    I am on page "https://js.devexpress.com/Demos/WidgetsGallery/Demo/Slider/Overview/jQuery/Light/"
    I run performance check {"reportFileName":"customname"}


-------- playwright lighthouse audit reports --------


performance record is 74 and desired threshold was 10
accessibility record is 78 and desired threshold was 30
best-practices record is 100 and desired threshold was 30
seo record is 92 and desired threshold was 30
pwa record is 30 and desired threshold was 30
  ✔ OK in 14844ms

 › [Suite Config] Reverted for Playwright

  OK  | 1 passed   // 16s

Parallel Executions

It's a little tricky to run lighthouse tests in parallel due to we need to set a specific port for each test, but it's not impossible. To do this we need to create a custom parallel execution, an example could be found at bin/parallel.js

Then your test file:

const {I} = inject()
let conf = require('codeceptjs').config.get()
let port
const urls = { homepage: 'https://js.devexpress.com/Demos/WidgetsGallery/Demo/Slider/Overview/jQuery/Light/'}

Feature('Performance tests')

Before(() => {
    conf.helpers.Playwright.chromium.args.forEach(arg => {
        if (arg.includes('remote-debugging-port') === true) {
            port = arg.split('=')[1]
        }
    })
})

Object.entries(urls).forEach(item => {
    const [pageName, pageUrl] = item
    Scenario.only(`Lighthouse audit test for ${pageName}`, async () => {
        I.amOnPage(pageUrl)
        await I.runPerformanceCheck({outputDir: 'hello', port})
    })
})

Allure report

Screenshot 2023-06-28 at 17 31 20 https://kobenguyent.github.io/codeceptjs-lighthouse-helper/#