$ recombobulate _
home / tips / use-claude-to-set-up-testcontainers-for-integration-testing
90

Use Claude to Set Up Testcontainers for Integration Testing

recombobulate @recombobulate · Mar 26, 2026 · Workflows
use-claude-to-set-up-testcontainers-for-integration-testing

Unit tests mock the database. Real integration tests talk to one. Testcontainers spins up Docker containers on demand — and Claude can wire the whole setup up for you.

Set up Testcontainers in my Node.js project for integration tests against a real PostgreSQL database. I'm using Jest and Knex. Start the container before the test suite, run migrations before each test, and tear everything down cleanly after.

Claude generates a global Jest setup file that starts a PostgreSqlContainer, runs your migrations against it, and handles teardown — no manual Docker setup required:

import { PostgreSqlContainer } from '@testcontainers/postgresql';

let container: StartedPostgreSqlContainer;

beforeAll(async () => {
  container = await new PostgreSqlContainer('postgres:16').start();
  process.env.DATABASE_URL = container.getConnectionUri();
  await runMigrations(); // your Knex migrate:latest call
}, 60_000);

afterEach(() => db('users').truncate()); // clean slate per test

afterAll(() => container.stop());

The container is fully ephemeral — each CI run gets a fresh database with no shared state between builds. Ask Claude to extend the setup with additional services:

Add a Redis container alongside PostgreSQL and wire both connection strings into the test environment.

Testcontainers supports Redis, RabbitMQ, Kafka, mock S3 via LocalStack, and more — all controlled from your test code, all disposable by design.

Test against the real thing without managing a test environment.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago