Supertest · Production Workflow และ Capstone
PostgreSQL Readiness ใน CI
เตรียม PostgreSQL service ให้พร้อมก่อนเริ่ม test
CI ต้องรอ PostgreSQL พร้อมจริง
การ start service container ไม่ได้แปลว่า database รับ connection แล้ว E2E job ต้องมี readiness check ก่อน migration และ test ไม่เช่นนั้น failure แรกจะเป็น connection refused ที่ไม่เกี่ยวกับ code
PostgreSQL service และ readinessYAML
ตัวอย่างเป็น GitHub Actions-style YAML; ชื่อ field จริงต้องตรวจตาม workflow ของ project
แยก infrastructure failure จาก test failure
| failure | สัญญาณ | แนวทางตรวจ |
|---|---|---|
| database ยังไม่พร้อม | connection refused | readiness/health check |
| schema ไม่ตรง | missing table/column | migration step และ Prisma schema |
| behavior ผิด | assertion failed | request/response และ application logs |
i
อย่าเพิ่ม retry ให้ assertion
retry เหมาะกับ readiness ที่มีเหตุผลด้าน timing แต่ไม่ควรใช้ซ่อน API behavior ที่ fail จริง