Level 4 · Full-Stack Application Development · Course 4.3 Backend with Node.js
Module 46: Backend Testing
Goal: test a backend at every level: unit tests for rules, integration tests for parts working together, API tests for real HTTP requests, with mocks where needed and coverage to find gaps. You'll finish the Course 4.3 project.
You'll need: your enquiries-api from Module 45, and Module 26's testing skills.
Lessons
- 1What to test in a backend15–25 minutes✓
- 2Unit tests for services15–25 minutes✓
- 3API tests with Supertest15–25 minutes✓
- 4Mocks and test doubles15–25 minutes✓
- 5Coverage and test habits15–25 minutes✓
🛠️Module practice: Course 4.3 project, an enquiries API
Complete the enquiries API:
- Layered Express API with validated input and consistent errors.
- Staff sign-in with sessions; admin-only actions (delete, assign).
- Attachments with safe uploads; structured logs; error reporting.
- Unit, integration and API tests, including every permission rule; coverage report.
- README with setup, environment variables, endpoints and test instructions. Commit.
✅Module check
Explain in a few sentences, in your own words:
How do you test a backend so you can trust it?
Show a good answer
A good answer mentions: many fast unit tests for services and schemas using in-memory repositories and fresh data per test; API tests that send real HTTP requests (with Supertest) to check status codes, bodies, sign-in, validation errors and that errors leak no details; permission tests for every rule; test doubles only at the edges (email, payments, time), including their failure paths; and coverage used to find untested risky code, not as a goal in itself. Tests run before every commit and in CI, and are never weakened to pass.
📝Module quiz
10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·
