This document explains how testing is organized across all services in the DeshCode microservices architecture, how Testcontainers are used for ephemeral databases and message queues, and how tests integrate with workers and Prisma migrations.
🐳 What Testcontainers Does Testcontainers is a Node.js library (originally from Java) that allows you to:
- Spin up Docker containers programmatically for testing.
- Provide isolated, ephemeral environments for databases, message brokers, or other services.
- Automatically clean up containers after tests finish.
- Integrate seamlessly with Jest, Mocha, or other test frameworks.
✅ Why Testcontainers is Useful
- Reliable integration tests: You test against real services (Postgres, RabbitMQ) instead of mocks.
- Consistency: Every test run starts from a clean slate.
- CI/CD friendly: Works in Docker-enabled CI environments (GitHub Actions, GitLab, etc.).
- Isolation: No need to install local Postgres or RabbitMQ, no conflicts with dev databases.
You can visit each service's tests directory for information on how tests are structured and run.