fifth commit
All checks were successful
Node API Test / test (push) Successful in 24s

This commit is contained in:
Gitea
2026-04-16 15:51:19 +05:30
parent dbda40e864
commit 6838b2754c
5 changed files with 4256 additions and 16 deletions

View File

@@ -14,7 +14,7 @@
# - run: echo "Hello from Gitea Actions" # - run: echo "Hello from Gitea Actions"
name: Node CI Test name: Node API Test
on: on:
push: push:
@@ -26,10 +26,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - uses: actions/checkout@v4
uses: actions/checkout@v4
- name: Setup Node.js - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20 node-version: 20

View File

@@ -0,0 +1,24 @@
const express = require("express");
const app = express();
app.use(express.json());
app.get("/", (req, res) => {
res.send("🚀 Home Route Working");
});
app.get("/health", (req, res) => {
res.json({
status: "OK",
message: "Server is healthy ✅"
});
});
module.exports = app;
// only start server if not testing
if (require.main === module) {
app.listen(3000, () => {
console.log("Server running on port 3000");
});
}

4200
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,10 +11,12 @@
"type": "commonjs", "type": "commonjs",
"main": "test.js", "main": "test.js",
"scripts": { "scripts": {
"test": "node test.js" "test": "jest",
"start": "node index.js"
}, },
"dependencies": { "dependencies": {
"express": "^5.2.1" "express": "^5.2.1",
"jest": "^30.3.0",
"supertest": "^7.2.2"
} }
} }

33
test.js
View File

@@ -1,9 +1,26 @@
console.log("Running CI test..."); // console.log("Running CI test...");
if (1 + 1 === 2) { // if (1 + 1 === 2) {
console.log("✅ TEST PASSED"); // console.log("✅ TEST PASSED");
process.exit(0); // process.exit(0);
} else { // } else {
console.log("❌ TEST FAILED"); // console.log("❌ TEST FAILED");
process.exit(1); // process.exit(1);
} // }
const request = require("supertest");
const app = require("./index");
describe("API Testing", () => {
test("GET / should return home message", async () => {
const res = await request(app).get("/");
expect(res.text).toBe("🚀 Home Route Working");
});
test("GET /health should return status OK", async () => {
const res = await request(app).get("/health");
expect(res.body.status).toBe("OK");
});
});