Supertest · Todo CRUD E2E
List, Filter และ Pagination
ทดสอบ collection response และ query behavior
List test ต้องตรวจ collection contract
GET /todos มักคืน `items` และ `total` พร้อม query สำหรับ filter หรือ pagination Test ต้องสร้างข้อมูลหลายรายการก่อน แล้วตรวจว่า response แสดงผลตาม query ไม่ใช่เพียงมี status 200
filter collectionTS
pagination มีทั้ง input และ metadata
| สิ่งที่ตรวจ | ตัวอย่าง | เหตุผล |
|---|---|---|
| items | จำนวนไม่เกิน limit | endpoint ไม่คืนข้อมูลเกินหน้าที่ขอ |
| total | จำนวนตาม filter ก่อนแบ่งหน้า | UI คำนวณจำนวนหน้าได้ |
| page/limit metadata | ตาม contract ถ้ามี | client รู้ว่ากำลังดูหน้าใด |
i
อย่าใช้ fixture แค่รายการเดียว
filter และ pagination จะพิสูจน์ไม่ได้ถ้า Arrange ไม่มีข้อมูลที่แยกกันให้เห็นผล