sixth commit
Some checks failed
Node API Test / test (push) Failing after 17s

This commit is contained in:
Gitea
2026-04-16 15:58:11 +05:30
parent 6838b2754c
commit 2132babc51
2 changed files with 8 additions and 4 deletions

View File

@@ -4,19 +4,23 @@ const app = express();
app.use(express.json()); app.use(express.json());
app.get("/", (req, res) => { app.get("/", (req, res) => {
res.send("🚀 Home Route Working"); res.json({
status: "OK",
message: "Home Route Working"
});
}); });
app.get("/health", (req, res) => { app.get("/health", (req, res) => {
res.json({ res.json({
status: "OK", status: "OK",
message: "Server is healthy" message: "Server is healthy"
}); });
}); });
module.exports = app; module.exports = app;
// only start server if not testing // only start server if not testing
// It ensures the server starts only when the file is run directly, not when it is imported for testing.
if (require.main === module) { if (require.main === module) {
app.listen(3000, () => { app.listen(3000, () => {
console.log("Server running on port 3000"); console.log("Server running on port 3000");

View File

@@ -13,9 +13,9 @@ const app = require("./index");
describe("API Testing", () => { describe("API Testing", () => {
test("GET / should return home message", async () => { test("GET / should return status ok", async () => {
const res = await request(app).get("/"); const res = await request(app).get("/");
expect(res.text).toBe("🚀 Home Route Working"); expect(res.body.status).toBe("ok");
}); });
test("GET /health should return status OK", async () => { test("GET /health should return status OK", async () => {