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

docker-modem-mock

v0.0.6

Published

A mock implementation of docker-modem for testing purposes

Readme

docker-modem-mock

A mock implementation of docker-modem for testing purposes. This package allows you to mock Docker API calls in your tests when your code interacts with Docker (e.g., creating containers), but you don't need a real Docker daemon or to test the actual container contents.

Features

  • Image Management: Pulling, building, listing, inspecting, and deleting images.
  • Container Lifecycle: Creating, starting, stopping, listing, and inspecting containers.
  • Fixture-based Responses: Use pre-recorded or custom fixtures to simulate Docker API responses for complex operations like pull and build.
  • Dockerode Integration: Seamlessly works with dockerode by replacing its underlying modem.

Installation

npm install docker-modem-mock --save-dev

Usage

Basic Setup with Dockerode

import Docker from "dockerode";
import { ModemMock, Fixtures } from "docker-modem-mock";

const docker = new Docker({
    modem: new ModemMock({
        mockFixtures: Fixtures.fromPath("./test/fixtures")
    })
});

Pulling an Image

const stream = await docker.pull("node:18");
stream.on("data", (chunk) => console.log(chunk.toString()));
stream.on("end", () => console.log("Pull complete"));

Building an Image

const stream = await docker.buildImage({
    context: "./path/to/context",
    src: ["Dockerfile", "index.js"]
}, {
    t: "my-image:latest"
});

Container Lifecycle

const container = await docker.createContainer({
    Image: "node:18",
    name: "my-container"
});

await container.start();
const inspect = await container.inspect();

console.log(inspect.State.Status); // "running"

await container.stop();

Fixtures Structure

The mock relies on a specific directory structure for fixtures:

  • records/{version}/image/{imageName}/{tag}.json: JSON file containing image inspection data.
  • records/{version}/pull/{imageName}/{tag}.jsonl: JSONL file containing streaming output for image pull.
  • records/{version}/build-{builderVersion}/{imageName}/{tag}.jsonl: JSONL file containing streaming output for image build.

API

ModemMock

Inherits from Modem.

  • constructor(options: Options)
    • mockFixtures: Optional Fixtures instance to load initial data.
  • registerFixtures(fixtures: Fixtures): Registers additional fixtures.
  • reset(): Resets the internal state (containers and images).

Fixtures

  • static fromPath(path: string): Creates a Fixtures instance from a filesystem path.
  • static fromFS(fs: FileSystem): Creates a Fixtures instance from a @wocker/core FileSystem.

License

MIT