Engineering Playbook
Test Levels

Integration Testing

Testing boundaries, Databases, and API endpoints.

Integration Testing

Unit tests prove logic works. Integration tests prove logic works together.

The Database Strategy

How to test code that reads/writes to SQL?

  1. In-Memory (SQLite): Fast, but risky. SQLite behaves differently than Postgres (e.g., missing JSONB functions).
  2. Docker Containers (Testcontainers): Spin up a real Postgres container for the test suite.
    • Setup: Start container -> Run Migrations -> Run Tests -> Destroy.
    • Verdict: The modern standard. Slightly slower, but 100% accurate.

API Testing

Testing your REST/GraphQL endpoints via HTTP calls (e.g., using Supertest).

  • Scope: Send request -> Check Response Code -> Check DB side effects.
  • Mocking: You usually mock external 3rd party APIs (Stripe, Twilio) but keep your internal Database real.