Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Test routes against a real or test database.
Integration Testing is easiest to learn by reading the example, changing it, and observing the result.
import { createLesson } from '../services/lessons.js';
test('createLesson rejects a short title', async () => {
await expect(createLesson({ title: 'a' }))
.rejects.toThrow('title');
});
test('createLesson returns a slug', async () => {
const lesson = await createLesson({ title: 'Express Routing' });
expect(lesson.slug).toBe('express-routing');
});Practice the Integration Testing example in a small scratch file, then explain what changed and why.