API Reference

Testcontainers

Node.js library that runs Docker containers to provide disposable databases and services for tests.

Official Documentation ↗
CompatibilityThis documentation covers version v10. Check the official docs for the latest API surface.

Installation

npmnpm install --save-dev testcontainers

Methods

Testcontainers starts real services in Docker for the duration of a test and cleans them up afterward.

Key Features

  • Real services instead of stubs
  • Automatic container lifecycle and cleanup
  • Wait strategies for readiness

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

API reference evidence

Fetched from official sources on 2026-11-08T09:53:13.312Z via WebFetch https://unpkg.com/[email protected]/build/index.d.ts.

FAQ

Do I need Docker installed?
Yes. Testcontainers requires a running Docker daemon, and tests will fail fast if it is unavailable.
How do I wait for readiness?
Use withWaitStrategy with a log message or port wait so the container is fully started before tests connect.
Will containers be cleaned up?
Yes. stop() removes them, and Ryuk reaps orphans; still call stop in afterAll to release resources promptly.