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

@stacks/api-test-toolkit

v1.13.0

Published

Test utilities for @stacks/api-toolkit

Readme

@stacks/api-test-toolkit

Test utilities for integration tests that need Docker-managed dependencies (for example Postgres).

Installation

npm install -D @stacks/api-test-toolkit

This package expects Docker to be available on the machine running tests.

Quick Start

Use the toolkit in your test global setup/teardown hooks.

import type { DockerTestContainerConfig } from '@stacks/api-test-toolkit';
import { dockerTestDown, dockerTestUp } from '@stacks/api-test-toolkit';

const postgres: DockerTestContainerConfig = {
  image: 'postgres:17',
  name: 'my-api-test-postgres',
  ports: [{ host: 5432, container: 5432 }],
  env: ['POSTGRES_USER=postgres', 'POSTGRES_PASSWORD=postgres', 'POSTGRES_DB=postgres'],
};

export async function globalSetup() {
  await dockerTestUp({ config: postgres });
}

export async function globalTeardown() {
  await dockerTestDown({ config: postgres });
}

API

dockerTestUp({ config })

Creates (or starts) the container and waits until it is reachable on TCP by default.

  • Pulls image if missing
  • Reuses an existing container with the same name
  • Waits for readiness unless waitForReady is set to false

dockerTestDown({ config })

Stops and removes the container if it exists.

  • No-op if the container is already absent

dockerTestLogs({ config, argv })

Streams or prints recent container logs.

  • Follows logs by default
  • Use argv: ['--once'] to print once and exit
  • -f / --follow force streaming mode

DockerTestContainerConfig

Required fields:

  • image: Docker image name (example: postgres:17)
  • name: Docker container name
  • ports: host/container port mapping array

Common optional fields:

  • host: bind address (default: 127.0.0.1)
  • waitPort: host-side port to probe for readiness
  • waitForReady: disable readiness check when set to false
  • env: environment variables (KEY=value)
  • entrypoint, command
  • volumes: mount strings in host:container format
  • extraHosts: hostname:ip entries
  • healthcheck: shell command passed as Docker CMD-SHELL
  • restartPolicy: no | always | on-failure | unless-stopped
  • labels
  • timeoutMs: readiness timeout (default: 120000)

Docker client environment

By default, Docker is accessed through:

  • DOCKER_SOCKET_PATH (defaults to /var/run/docker.sock)

If DOCKER_HOST is set, it is used instead.

Notes

  • Prefer import type for TypeScript-only symbols:
    • import type { DockerTestContainerConfig } from '@stacks/api-test-toolkit'
  • Container names should be unique per test suite to avoid clashes.

License

Apache 2.0