Why automated tests
A week after shipping auth, someone tweaks the Zod schema for login and accidentally breaks the username field. Nobody notices until a customer emails to say they cannot log in. This is the scenario automated tests exist to catch. Manual Postman testing works right up until you have to do it for every change on every feature.
The testing pyramid
Many fast unit tests at the bottom. A handful of integration tests in the middle. A few end-to-end tests at the top.
Unit tests check a single function in isolation. They are fast, cheap to write, and you want a lot of them. Integration tests check how parts work together, usually including a real database. They are medium speed and catch the most useful bugs. End-to-end tests drive the whole system through a browser or API. They are slow and flaky, so you keep them rare. This masterclass leans on integration tests, the sweet spot.
Because you will not do it for every endpoint every time. Automated tests run on every commit, catch bugs while the code is still fresh in your head, and give future-you a safety net when you refactor. The first time your test suite catches a regression before deploy, the hours you spent writing tests pay themselves back.
Quiz: Quiz
Loading practice…