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 🙏

© 2026 – Pkg Stats / Ryan Hefner

snapy

v0.1.6

Published

Webpack based, snapshot only test runner

Readme

Snapy

Webpack based, snapshot only test runner. Currently nodejs only, but with clientside and E2E testing in planning.

Features

  • Snapshots only - forces you to do proper tests of input -> output
  • Interactively shows you the output and asks about it
  • Uses webpack bundles to track changes
  • Watches test files and dependencies
  • Static analysis of tests to make writing them as easy as possible

Install

npm install --save-dev snapy

Usage

// ./test/test.js
// snapy tries to load all files in test directory by default
{test} = require("snapy")
test((snap) => {
  snap({obj: true})
})
# in terminal
snapy --help

# usage: snapy <options> (config file)

# options:
# -w, --watch         restart snapy on changes in config

# config file is optional and defaults to "snapy.config.[js|json|coffee|ts]"
# in "test/" and "/"

snapy.config

Read by read-conf, from ./ or ./test/ by default.

// ./test/snapy.config.js
module.exports = {

  // Disable some of the default plugins
  // $item (String) Package name or filepath (absolute or relative to cwd) of plugin
  disablePlugins: null, // Array

  // Snapy plugins to load
  // type: Array
  // $item (String) Package name or filepath (absolute or relative to cwd) of plugin
  plugins: ["snapy-cache","snapy-obj","snapy-entry","snapy-promise","snapy-transform-obj","snapy-filter-obj"],

  // Will also run tests from unchanged chunks
  runAll: false, // Boolean

  // Environment where the tests are run
  target: "node", // String

  // Timeout applied on all preparation, test and cleanup calls
  timeout: 2000, // Number

  // Level of logging
  verbose: 1, // Number

  // webpack configuration which will be used by merging
  webpack: {}, // Object

  // Path of webpack.config file to use for testing
  webpackFile: null, // String

  // …

}

Plugins

You should read the (short) docs of the bold ones.

Activated by default:

Activated by target: "node"

Additional

Writing tests

The API is small but powerful:

// ./test/someFile.js
{test, prepare, after, getTestId} = require("snapy")

// code outside will be called before all tests

// prepare(fn)
// fn will be called before each test and takes two arguments:
// state (optional) a state given by a test
// cleanUp(fn) registers a fn which will be called after each test
// you can return a value, which will be passed to the test
prepare((state, cleanUp) => {
  // do something
  cleanUp( => {
    // cleanup what you did
  })
  
  // getTestId()
  // provides you with an unique identifier for current running test
  // this is important as some tests may run in parallel on different threads
  portToUse = 8080+getTestId()
  return processedState
})

// test(state, fn)
// state is optional, and will be passed to prepare call
// fn takes two or three arguments
// depending if there is a returned value from prepare
// snap(obj) will take a snapshot and test it against previous values
// processedState: return value of prepare
// cleanUp(fn) registers a fn which will be called after this test
test(state, (snap, processedState, cleanUp) => {
  snap({obj: true})
  cleanUp( => {
    // cleanup what you did
  })
})


// after(fn)
// registers a fn which will be called after all tests
after( => {
  // more cleanUp
})

Caveats

As the tests are statically analysed, you are not allowed to do one of the following:

  • don't rename test or snap
{test:tst} = require("snapy") // won't work
test((sn) => {sn({obj:true})}) // won't work
  • don't use snap in conditional statements or loops
test((snap) => {
  [1,2].forEach((i) => {snap({obj:i})}) // won't work
})
  • don't define the test outside of the test call
t = (snap) => {snap({obj:true})}
test(t) // won't work

License

Copyright (c) 2018 Paul Pflugradt Licensed under the MIT license.