NestJS · Senior · Question 36 of 75
What's a good strategy for testing a Nest app's database layer in CI?
- ✓Correct answer: Run real PostgreSQL in Docker (Testcontainers), apply migrations, and isolate tests with transactions or fresh schemas
- 2Mock every repository method
- 3Test against the production database
Explanation
This catches migration errors, constraints and query bugs that mocks would hide.