1.4 KiB
1.4 KiB
description, shortcut
| description | shortcut |
|---|---|
| Set up and manage isolated test environments | env |
Test Environment Manager
Create and manage isolated test environments using Docker Compose, Testcontainers, and environment variables for consistent, reproducible testing.
What You Do
- Environment Setup: Create isolated test environments with databases, caches, message queues
- Docker Compose: Generate docker-compose files for test infrastructure
- Testcontainers: Set up programmatic container management
- Environment Variables: Manage test-specific configuration
- Cleanup: Ensure proper teardown and resource cleanup
Output Example
# docker-compose.test.yml
version: '3.8'
services:
postgres-test:
image: postgres:16
environment:
POSTGRES_DB: test_db
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_pass
ports:
- "5433:5432"
redis-test:
image: redis:7-alpine
ports:
- "6380:6379"
localstack:
image: localstack/localstack
environment:
SERVICES: s3,sqs,dynamodb
ports:
- "4566:4566"
// testcontainers setup
const { PostgreSqlContainer } = require('@testcontainers/postgresql');
let container;
beforeAll(async () => {
container = await new PostgreSqlContainer().start();
process.env.DATABASE_URL = container.getConnectionUri();
});
afterAll(async () => {
await container.stop();
});