Supertest · Todo CRUD E2E
Cross-Endpoint State Flow
เชื่อม create, read, update และ delete เป็น behavior เดียว
เชื่อมหลาย endpoint เป็น behavior เดียว
ผู้ใช้ไม่ได้เรียก endpoint แยกขาดจากกันเสมอ Flow จริงอาจเป็น create → list → read → patch → delete การทดสอบ cross-endpoint ช่วยจับปัญหาการ map id, state persistence และ response contract ที่ test ราย endpoint อาจไม่เห็น
state flow ข้าม endpointTS
แยก flow test กับ focused test
| รูปแบบ | หน้าที่ | ข้อควรระวัง |
|---|---|---|
| focused test | พิสูจน์ branch เดียว เช่น 404 | failure ชี้จุดแคบ |
| cross-endpoint flow | พิสูจน์ journey ต่อเนื่อง | ถ้ายาวเกินไป debug ยาก |
| capstone | ตรวจ suite ที่จัดระบบแล้ว | ควรประกอบจาก pattern ที่เรียน ไม่ใช่สร้างแนวคิดใหม่ |
กฎสำคัญ
signal
assert จุดเปลี่ยน state
ไม่ต้อง assert ทุก field ทุก step แต่ต้องตรวจผลที่ทำให้ step ถัดไปมีความหมาย
cleanup
cleanup หลัง flow
flow ยาวยิ่งมีโอกาสทิ้ง state มาก จึงต้องใช้ fixture/reset strategy เดียวกับ test อื่น