NestJS
NestJS Controller Testing
บทนี้ใช้โดเมน Todo และจัดแบบ CRUD + nested test cases เพื่อให้ทดสอบ controller ได้เป็นระบบในระดับ unit-only โดยโฟกัส HTTP contract, input mapping, service delegation และ error mapping อย่างชัดเจน
Controller Contract First
ให้มอง `TodoController` เป็นชั้น HTTP boundary ที่รับผิดชอบ mapping และ response contract ส่วน business logic ให้พิสูจน์ผ่าน service mock เพื่อให้ test อ่านง่ายและไม่ brittle
Advanced Controller Testing Playbook
แยกการทดสอบ Todo Controller แบบ unit-only ด้วย accordion ชั้นนอก (CRUD) และ nested test cases เพื่อดู mapping, delegation, contract และ error handling ได้เร็วขึ้น