Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Send fake requests to your app and assert responses.
HTTP Tests with Supertest is easiest to learn by reading the example, changing it, and observing the result.
// npm install --save-dev jest supertest
import request from 'supertest';
import app from '../app.js';
test('GET /api/lessons returns 200', async () => {
const res = await request(app).get('/api/lessons');
expect(res.status).toBe(200);
expect(Array.isArray(res.body.lessons)).toBe(true);
});Practice the HTTP Tests with Supertest example in a small scratch file, then explain what changed and why.