Module 61: Database Integration

Lesson 5 of 5 · 15–25 minutes

Testing with a real database

🏠The everyday picture

Rehearsing a play on the actual stage, with the real lights and props, before opening night, rather than only in a practice room.

📘What it really is

🖱️Try it

Set up a crm_test database and an npm script that runs migrations and integration tests against it. Write tests for: a duplicate email being refused; deleting a customer with orders being refused; an order transaction rolling back when stock is insufficient; and organisation isolation under RLS.

✅Quick check

Why aren't in-memory repository tests enough?

Show the answer

They can't check real SQL, constraints, transactions or RLS; only a real database can.

How do you keep tests from affecting each other's data?

Show the answer

Reset data before runs and roll back or truncate between tests.

← PreviousSupabase and backend-as-a-service
ProLearners Assist