16 lines
528 B
JavaScript
16 lines
528 B
JavaScript
import app from "../src/index.js"; // สมมติว่าคุณ export app จาก src/index.js
|
|
import request from "supertest";
|
|
|
|
// ปิด server หลังจากเทสเสร็จ
|
|
afterAll((done) => {
|
|
app.server.close(done);
|
|
});
|
|
|
|
describe("GET /health", () => {
|
|
it("should respond with 200 OK and a health message", async () => {
|
|
const response = await request(app).get("/health");
|
|
expect(response.statusCode).toBe(200);
|
|
expect(response.text).toContain("Backend is healthy");
|
|
});
|
|
});
|