In plain words
An integration test runs several real parts together, such as an API route, its queries and the actual Postgres schema, to catch the mistakes that only appear where the parts meet.
Where you see it
Every unit test for Harbor's invite flow passes, yet inviting a second teammate fails on staging because a unique constraint on team_members rejects the insert. A test that called the real route against a local test database would have hit the same error on your laptop.
What goes wrong
- Running them against a shared database
Tests that write to staging leave junk behind and fail when two runs overlap. Give tests their own database, such as Postgres in Docker or the Supabase local stack, and reset it between tests.
- Mocking the database everywhere
SQL that works against a mock can fail in Postgres: a missing column, a constraint, a type mismatch. Keep at least one test per route that talks to a real database with every migration applied.
- Testing every detail at this level
Integration tests take seconds where unit tests take milliseconds. Use them for the seams, such as routes, queries and webhook handlers, and keep detailed logic checks in unit tests.
What to tell your agent
Quick check
Sign in to earn +10 XP for itUnit tests for Harbor's invite flow all pass, but inviting a second teammate fails on staging with a duplicate key error. Which test would have caught it?