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

@zyplux/tests-fixtures

v0.5.1

Published

Story-test fixtures for zyplux workspaces: Node exec fake, console capture, fetch routing, temp dirs, domain matchers, and vitest test.extend bases per app type

Readme

@zyplux/tests-fixtures

Story-test fixtures for Node CLIs and libraries. Fakes swap in at the lowest boundary (node:child_process, node:readline/promises, node:timers/promises, fetch, console, process.env) so tests exercise only public interfaces.

Install

pnpm add -D @zyplux/tests-fixtures

Each fake needs the Node module it stands in for mocked in that project's own vitest setup file — only the modules whose fakes you use:

import { vi } from 'vitest';

vi.mock('node:child_process', async importOriginal => {
  const actual = await importOriginal<typeof import('node:child_process')>();
  return { ...actual, spawn: vi.fn(actual.spawn) }; // shell fake
});
// node:readline/promises -> createInterface (prompt fake); node:timers/promises -> setTimeout (instant sleeps)

Each factory wraps the original, so the module stays fully live until a fake installs an implementation. A fake whose module is unmocked says which one to add.

Use

Pick a base per app type, extend it with suite fixtures, and keep the binding named test:

import { cliTest } from '@zyplux/tests-fixtures/story';

export const test = cliTest;
export { describe, expect } from 'vitest';
import { describe, expect, test } from '#fixtures';

describe('1.1 pushing a branch', () => {
  test('1.1.1 pushes and reports the PR url', async ({ logs, shell }) => {
    shell.on('git rev-parse --abbrev-ref HEAD', 'feat-x');
    shell.on('git push', '');

    await runPushBranch({ command: 'push-branch', hold: false, ready: false });

    expect(shell).toHaveRun('git push --set-upstream origin feat-x');
    expect(logs).toHaveLogged('PR (draft): https://github.com/acme/repo/pull/1');
  });
});

Entry points

There is no barrel — import each fixture from its own subpath: /story (libraryTest, cliTest, makeFixture), /shell, /console, /fetch, /fs, /prompt, /cli, /matchers.

Bases

  • libraryTest — lazy fixtures: shell (fake node:child_process spawn, installed only when destructured), tempDir (auto-removed scratch directory with path, write, exists).
  • cliTest — extends libraryTest; auto-silences and captures console (logs), makes node:timers/promises sleeps instant; adds lazy network (fake fetch), prompt (fake node:readline/promises interface that accepts and records every question), and env (set(name, value) stubs an env var for the test).

Fakes

  • createShellFake() — routes commands (on(pattern, ...replies), later routes win, the last reply repeats; otherwise(reply) sets a fallback, unrouted commands throw) and records calls ({ argv, cwd?, env?, program, stdin? }), commands (rendered strings), commandsMatching(pattern).
  • createConsoleCapture() — records logLines/warnLines/errorLines.
  • createFetchFake() — routes urls (on(prefixOrRegExp, reply), otherwise(reply)) and records requests; okResponse()/notFoundResponse() build replies.
  • createPromptFake() — accepts every question() call and records messages.
  • createTempDir()path, write(relativePath, content), exists(relativePath), remove().

Matchers

Importing a base registers domain matchers via expect.extend:

  • expect(shell).toHaveRun(command) — the exact rendered command ran.
  • expect(shell).toHaveRunMatching(pattern) — some command matches (string = command prefix at a word boundary, same as on; RegExp = test); negate with .not for "never ran".
  • expect(logs).toHaveLogged(line?) / toHaveWarned(line?) / toHaveErrored(line?) — a captured line equals the string (or matches the RegExp); with no argument, that the channel captured anything, so .not.toHaveWarned() asserts silence.