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

pretty-node-snapshot

v0.0.2

Published

Readable, Jest-style snapshot formatting and path resolution for Node.js native test runner.

Readme

pretty-node-snapshot

build status code coverage npm package license

Readable, Jest-style snapshot formatting and path resolution for Node.js' built-in test runner (node:test).

node:test ships with basic snapshot testing (t.assert.snapshot() / --test-update-snapshots), but by default it serializes values with JSON.stringify and stores snapshots next to the test file with a .snapshot extension. This package gives it a more familiar, Jest-like setup:

  • Readable serialization via pretty-format — the same formatter Jest uses — with a fallback to util.inspect when pretty-format isn't installed.
  • Familiar snapshot layout: files are resolved into a __snapshots__/ directory alongside each test file (e.g. test/__snapshots__/index.test.js.snap), instead of a sibling .snapshot file.

Requirements

  • Node.js >= 24

Install

npm install --save-dev pretty-node-snapshot

pretty-format is an optional dependency. Install it for nicely formatted, colorized-when-supported snapshots:

npm install --save-dev pretty-format

If it isn't installed, serialization falls back to util.inspect automatically — no configuration needed.

Usage

Automatic setup (recommended)

Import pretty-node-snapshot/register before your tests run to automatically configure both the serializer and the snapshot path resolver. The easiest way is via Node's --import flag:

node --test --import pretty-node-snapshot/register

Or through a config file (node --experimental-config-file=./node.config.json):

{
  "nodeOptions": {
    "import": ["pretty-node-snapshot/register"]
  },
  "test": {
    "test": true
  }
}

If the node:test snapshot API isn't available (e.g. older Node.js versions), a warning is logged and nothing else is registered.

Manual setup

Use the individual exports from pretty-node-snapshot for more control:

import { configureSnapshotSerializer, configureSnapshotPathResolver } from 'pretty-node-snapshot';

configureSnapshotSerializer();
configureSnapshotPathResolver();

Or build a serializer/resolver without registering it globally:

import { prepareSerializer, preparePathResolver } from 'pretty-node-snapshot';

const serialize = prepareSerializer();
const resolvePath = preparePathResolver({ dirSnapshot: '__custom__' });

API

  • prepareSerializer(options?, formatter?) — returns a (value) => string serializer. Strings are passed through unchanged; other values are formatted with pretty-format (or util.inspect as a fallback). options are forwarded to the formatter.
  • configureSnapshotSerializer(options?) — registers prepareSerializer(options) as the default snapshot serializer via node:test's snapshot.setDefaultSnapshotSerializers.
  • preparePathResolver(options?) — returns a (testFilePath) => string resolver that maps a test file to <dir>/<dirSnapshot>/<basename>.snap. options.dirSnapshot defaults to __snapshots__.
  • configureSnapshotPathResolver(options?) — registers preparePathResolver(options) via node:test's snapshot.setResolveSnapshotPath.
  • loadFormatter(importPrettyFormat?) — attempts to dynamically import pretty-format, resolving to null if it isn't installed.
  • registerSnapshot(snapshotApi) (from pretty-node-snapshot/register) — wires up the serializer and path resolver on the given node:test snapshot namespace, or warns if it's unavailable/incomplete.

Development

This project is managed with projen — configuration lives in .projenrc.ts, and most files are generated. Run npx projen after editing .projenrc.ts to regenerate them.

npm run test        # run tests with coverage and lint
npm run test:watch  # run tests in watch mode
npm run eslint       # lint only

Tests run against Node's native test runner using the config in node.config.json. Source files under src/ are typed via JSDoc and checked against tsconfig.projen.json (no build step or TypeScript runtime dependency required).