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

snapscreen

v1.0.3

Published

When you call `snapshot(name)` it will take a screenshot at that point and store it under `./screenshots/actual`, it will compare it to the corresponding file under `./screenshots/expected` and return the number of pixels difference. If the difference is

Downloads

8

Readme

Snapscreen

When you call snapshot(name) it will take a screenshot at that point and store it under ./screenshots/actual, it will compare it to the corresponding file under ./screenshots/expected and return the number of pixels difference. If the difference is non-zero, a ${name}-diff.png file will also be created highlighting the different pixels.

The expected/actual folders are automatically created if they don't exist. If there isn't a corresponding expected file (e.g. on first run), it will automatically be created too - i.e. there is zero set up.

To force update a screenshot on subsequent runs you can set the environment variable SNAPSHOTS equal to the screenshot name, or set it to true to overwrite all the expected screenshots.

const { test } = require('tap')
    , { startup } = require('./start-application')
    
test('home-page', async ({ plan, same }) => {
  plan(2)
  const { page, destroy } = await startup()
      , snapshot = await require('snapscreen')(page)

  await page.waitFor('.content')

  same(await snapshot('home-page'), 0)

  await page.click('.more')

  same(await snapshot('home-page-2'), 0)

  await destroy()
})

Additional Options

const snapshot = await require('snapscreen')(page, { 
  width = 1920
, height = 1200
, dir = dirname(module.parent.filename) 
})

snapshot(name, { 
  update = process.env.SNAPSHOTS == 'true' || process.env.SNAPSHOTS == name
, fullPage = false
, threshold = 0.5
, scrollX = 0
, scrollY = 0
})
  • width/height: set the width/height of the screenshots
  • dir: the base directory where the screenshots will be created, defaults to where the module is called from
  • update: overwrite the expected file with the actual file, defaults to true if the environment variable SNAPSHOTS is set to true or the name of the screenshot.
  • fullPage: take a full page screenshot rather than cropping to specific width/height
  • scrollX/scrollY: scroll to this position before taking the screenshot