Files
HexaHost-GameCloud/apps/api/test/health.test.js
smueller 8d659317b9
Some checks failed
CI / Node — lint, typecheck, test, build (push) Failing after 9s
CI / Go — node-agent tests (push) Failing after 21s
CI / Go — edge-gateway build (push) Successful in 12s
Refactor health tests to remove explicit type annotations in Promises. Update web package version and scripts for Next.js. Enhance TypeScript configuration with new options and paths. Add Prisma commands to database package scripts. Include additional devDependencies across packages.
2026-06-26 10:49:08 +02:00

32 lines
1000 B
JavaScript

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import http from "node:http";
describe("api health", () => {
it("returns ok for healthz", async () => {
const server = http.createServer((req, res) => {
if (req.url === "/healthz") {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ status: "ok", service: "api" }));
return;
}
res.writeHead(404);
res.end();
});
await new Promise((resolve) => server.listen(0, resolve));
const addr = server.address();
assert.ok(addr && typeof addr === "object");
const port = addr.port;
const response = await fetch(`http://127.0.0.1:${port}/healthz`);
assert.equal(response.status, 200);
const body = (await response.json()) as { status: string };
assert.equal(body.status, "ok");
await new Promise((resolve, reject) =>
server.close((err) => (err ? reject(err) : resolve())),
);
});
});