Tests you can trust: testing an API without the pain
Tests that break for no reason teach people to ignore tests. A few habits keep them fast, focused and honest.

A slow, flaky test suite is worse than having no tests at all. When tests fail randomly, people learn to ignore red, and the day a real bug appears, nobody notices.
The goal of testing is not a coverage number. It is confidence: being able to change code on a Thursday afternoon and deploy without fear. These habits get trainees there.
Test behaviour, not implementation
A good test describes what the API promises, from the outside. If you rename an internal function and a test breaks, the test was checking the wrong thing.
it("returns 404 for an unknown course", async () => { const res = await request(app).get("/v1/courses/999"); expect(res.status).toBe(404); expect(res.body.error).toBeDefined();});Give every test its own data
Tests that share data depend on the order they run in. Create what each test needs at its start and clean it up at its end, so any test can run alone and still pass.
Keep the fast tests fast
- Run the quick tests on every change, in seconds.
- Run slower end-to-end tests before merging.
- If a test is flaky, fix it or delete it the same day.
A test you don't trust is just noise.
How we practise it
In the Backend path, every pull request needs tests for the behaviour it adds, and reviewers try to break the code with inputs the tests forgot. It is a friendly competition, and it produces some of the most careful backend developers we train.





