Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Test routes and middleware with confidence.
Testing Express Apps 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 Testing Express Apps example in a small scratch file, then explain what changed and why.