Mailpit
A local SMTP server and web inbox for testing the emails your app sends.
Spin up real databases and services in Docker from inside your tests.
No votes yet. Tried it? Be the first to say.
One vote per person. No account needed.
Testcontainers libraries start throwaway containers (Postgres, Redis, Kafka and more) for a test run and clean them up afterwards. Your integration tests hit the real thing instead of mocks.
Mocked database layers, shared test databases, hand-written docker-compose setup
Bugs slip through because your tests mock the database or message broker.
Start Postgres, MySQL, Redis, Kafka, MongoDB, LocalStack and many more in Docker, straight from test code.
Pre-configured modules give you a typed container with helpers like connection strings and credentials.
Tests only start once the service is actually ready (log message, port, HTTP health check), not just when the container starts.
A small "reaper" container removes everything after the run, even if your test process crashes.
Spin up an existing docker-compose file for a test run when you need several services together.
The same model and module names across Java, Go, .NET, Node.js, Python, Rust and others.
Testcontainers talks to the Docker API from inside your test process. When a test asks for, say, a Postgres container, the library pulls the image if needed, starts it on a random free port, waits until the database is genuinely accepting connections, and hands you the connection details. A small companion container watches your test session and removes everything when it ends, so crashed runs don't leave containers behind.
import { PostgreSqlContainer, type StartedPostgreSqlContainer } from '@testcontainers/postgresql';
import { afterAll, beforeAll, expect, test } from 'vitest';
import pg from 'pg';
let container: StartedPostgreSqlContainer;
let client: pg.Client;
beforeAll(async () => {
container = await new PostgreSqlContainer('postgres:16-alpine').start();
client = new pg.Client({ connectionString: container.getConnectionUri() });
await client.connect();
// run your migrations here
}, 60_000);
afterAll(async () => {
await client.end();
await container.stop();
});
test('stores and reads a user', async () => {
await client.query('CREATE TABLE users (id serial PRIMARY KEY, name text)');
await client.query("INSERT INTO users (name) VALUES ('Ada')");
const { rows } = await client.query('SELECT name FROM users');
expect(rows[0].name).toBe('Ada');
});postgres:16-alpine, not postgres:latest) so tests are reproducible.npm i -D testcontainers @testcontainers/postgresql
// in a test:
// const pg = await new PostgreSqlContainer("postgres:16").start(); Start services before the test run. Simpler, but shared state and manual lifecycle.
Very fast, but behave differently from the real engine in subtle ways.
Fast and isolated, but tests the mock rather than your SQL.
Other tools that share topics with Testcontainers.
A local SMTP server and web inbox for testing the emails your app sends.
A fast JavaScript runtime, package manager, bundler and test runner in one binary.
A small, fast container runtime for macOS, Windows and Linux that replaces Docker Desktop.