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

web-vitals-test

v4.2.0

Published

Test for Web Vitals metrics

Downloads

50

Readme

web-vitals-test

Test Automation for Web Vitals

This typescript package enables you to automate testing for Web Vitals (https://web.dev/). It relies on web vitals Library and capabilities of puppeteer automation tool for browsers.

How to use

Initialization

Express server is run in the background on port 3000. It can be overridden using init method. Ensure that through out execution it is only called once.

//import {WebVitalsTest as Controller} from  'web-vitals-test';
Controller.init({port:3000});;

Pass puppeteer Page to Controller

Send Puppeteer Page object to Controller so that it can track web vital metrics and further Measure methods can be executed.

const  browser = await  puppeteer.launch({headless:false,defaultViewport:{height:1200,width:1950},args:['--start-maximized' ]});
await  Controller.setBrowser(browser);

Navigate to URL

Use inbuilt method to open URL. Action name is mandatory, that will be used in the HTML report. By design, only CLS data is available at page load.

 let result = await Controller.goTo_ClickAndMeasure(
  'http://automationpractice.com/',
  'InitialLoad',
  { value: '[id="search_query_top"]' },
  { waitFor: 1000 },
);

OR

 let result = await Controller.goToAndMeasure('http://automationpractice.com/', 'InitialLoad', {
  waitUntil: 'networkidle2',
});

Interaction with Browser

Currently click, select and scroll events are supported to measure the metrics, For all the other interaction, use puppeteer methods.

await Controller.clickAndMeasure('ClickElement',{ value : '[id="search_query_top"]' });

await  Controller.scrollAndMeasure('ScrollDown',{down:  1000,right:0});
await  Controller.scrollAndMeasure('ScrollUp',{down: -1000,right:0});

await Controller.selectAndMeasure('SelectPrice',{ value: '[id="group_1"]'},'3')

await WebVitalsTest.typeAndMeasure('type',{ value: '#sli_search_1' },{text:'shirt',pressEnter:true},{waitUntil:'networkidle2'} );

Report

Report is available in JSON Format

Web-Vitals-Test-Reporter can be used in the conjuction to generate HTML report.

Release History

4.1.0

Breaking Changes - Removed LSN as new CLS definition is based on LSN.

3.1.10

add option not to create report

3.1.8

Bugfix - network and cpu emulation

3.1.7

add hoverAndMeasure

3.1.6

no process event listener leak and detach CDP session after setting emulation and cpu throttle

3.1.5

bug fixes for typeAndMeasure and status

3.1.4

add error status in action

3.1.1

make reporter global so that multiple controllers can be used parallelly.

3.0.11

add deviceScaleFactor in emulation , add optional think time to wait before metrics are measued  and fix scrollUp bug that was not working

3.0.10

Introduced TypeAndMeasure and exposed Controller object for parallel execution

3.0.9

Correct action name for LCP PO reporting on page load

3.0.1 -> 3.0.8

Bug fixes and support for LCP PO and LCP web vitals both

3.0.0

support for LSN (Layout Shift Normalized) metric that would replace CLS