forked from Lilly-Protocol/lily-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.test.ts
More file actions
27 lines (21 loc) · 879 Bytes
/
Copy pathcore.test.ts
File metadata and controls
27 lines (21 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import request from "supertest";
import { describe, expect, it } from "vitest";
import { createApp } from "../src/app";
import { apiRouter } from "../src/routes";
describe("core application routes and error handling", () => {
const app = createApp();
it("serves the root service status route", async () => {
const response = await request(app).get("/");
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
expect(response.body.message).toContain("running");
});
it("handles unhandled server errors gracefully through error middleware", async () => {
apiRouter.get("/error-trigger", () => {
throw new Error("Simulated unhandled exception");
});
const response = await request(app).get("/api/v1/error-trigger");
expect(response.status).toBe(500);
expect(response.body.success).toBe(false);
});
});