Supertest · ส่งข้อมูลใน Request
Form Fields
ส่ง form data ด้วย `.type()` และ `.field()`
ส่ง `application/x-www-form-urlencoded`
Form fields เหมาะกับ endpoint ที่รับข้อมูลแบบ HTML form หรือ legacy authentication flow ใช้ `.type('form')` แล้วส่ง object เข้า `.send()` หรือใช้ `.field()` เมื่อกำลังสร้าง multipart request
ตรวจว่า server อ่าน field ถูก
การ assert ที่มีประโยชน์คือดูผลลัพธ์จาก field เช่น login สำเร็จได้ token หรือ form ที่ขาด email ได้ 400 ไม่ใช่ assert ว่า Supertest เรียก `.type()` แล้วเท่านั้น
กฎสำคัญ
mapping
ชื่อ field ต้องตรง DTO
`email` กับ `username` อาจมีความหมายต่างกัน แม้ endpoint จะเป็น login เหมือนกัน
safety
secret อยู่ใน fixture ที่ปลอดภัย
ใช้ credential ของ test user ไม่ใช้ password จริง และไม่พิมพ์ secret ลง failure output โดยไม่จำเป็น