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

lets-test

v2.0.1

Published

configuration for running component, performance and security tests

Downloads

5

Readme

lets-test

It lets you test without doing all the nasty configuration. It has support for running:

Coming soon:

  • tool for mocking api
  • visual regression tests

Installation

npm i lets-test --save-dev

How to run wdio tests

WebdriverIO is configured to run with Mocha and Jest Expect.

  1. After installing the package, create the following folder structure for your *.spec.js test files.
    test/
    -- wdio/
    -- -- *.spec.js
  2. For running your tests use:
    • to run tests in mobile, tablet and desktop using headless
    npx lets-run-wdio
    • to run on mobile only use DEVICE, it can be "mobile", "tablet" or "desktop"
    DEVICE=mobile npx lets-run-wdio
    • if you don't what to run headless use NOT_HEADLESS
    NOT_HEADLESS=true npx lets-run-wdio

How to run performance tests

  1. After installing the package, create the following folder structure.
    test/
    -- lighthouse/
  2. Inside test/lighthouse/ you need to create an urls.json file, this will tell lighthouse what URLs to test and what values to expect.
    Here is an example:
    {
      "urls": [
        {
          "name": "The name of the page (for the report)",
          "url": "http://localhost:8080",
          "optimal": {
            "mobile": {
              "speedIndex": 3500,
              "firstMeaningfulPaint": 3800,
              "domSize": 1500,
              "estimatedInputLatency": 2400,
              "totalByteWeight": 1638400,
              "criticalRequestChains": 2
            },
            "tablet": {
              "speedIndex": 3700,
              "firstMeaningfulPaint": 4200,
              "domSize": 1500,
              "estimatedInputLatency": 4800,
              "totalByteWeight": 1638400,
              "criticalRequestChains": 2
            },
            "desktop": {
              "speedIndex": 2400,
              "firstMeaningfulPaint": 4400,
              "domSize": 1500,
              "estimatedInputLatency": 2400,
              "totalByteWeight": 1638400,
              "criticalRequestChains": 2
            }
          }
        }
      ]
    }
    As you can see, "urls" it's an array so you can specify multiple URLs to be tested.
    Feel free to set your optimal values (speedIndex, domSize...) as you consider best for your application.
  3. For running your tests use:
    DEVICE=mobile npx lets-run-lighthouse
    DEVICE can be "mobile", "tablet" or "desktop"

How to run security tests

  1. After installing the package, create the following folder structure.
    test/
    -- zap/
  2. Inside test/zap/ you need to create an alerts.json file, this will tell zap how many "high", "medium" and "low" alerts you expect to have on each device (mobile, tablet and desktop).
    Here is an example:
    {
      "mobile": {
        "high": 0,
        "medium": 1,
        "low": 2
      },
      "tablet": {
        "high": 0,
        "medium": 1,
        "low": 2
      },
      "desktop": {
        "high": 0,
        "medium": 1,
        "low": 2
      }
    }
  3. Generate the ZAP report:
    • first you need to install zap on you machine, just download the Cross Platform Package. This runs with JAVA so make sure you also have JAVA installed.
    • to simplify the command line it's best to create an env variable in you system that points to the ZAP installation folder something like: $ZAP_PATH
    • now go to your project root and run ZAP like this: (replace localhost:8080 with your application homepage)
    java -jar $ZAP_PATH/zap-2.7.0.jar -cmd -installdir $ZAP_PATH -quickurl http://localhost:8080 -quickout $PWD/zap-report.xml
  4. So step 3 will generate a zap-report.xml file in the root of you project.
    To see if the zap report contains the same number of alerts that you expect, hopefully 0, run:
    DEVICE=mobile npx lets-run-zap
    DEVICE can be "mobile", "tablet" or "desktop"

How to run SSR (Server side rendering) tests

  1. After installing the package, create the following folder structure.
    test/
    -- ssr/
  2. Inside test/ssr/ you need to create an urls.json file, this will tell our script what URLs to test.
    Here is an example:
    {
      "urls": [
        {
          "name": "The name of the page (for the report)",
          "url": "http://localhost:8080"
        }
      ]
    }
    As you can see, "urls" it's an array so you can specify multiple URLs to be tested.
  3. To run the tests use:
    DEVICE=mobile npx lets-run-ssr
    DEVICE can be "mobile", "tablet" or "desktop"