import { afterEach, describe, expect, it, jest, spyOn } from "bun:test"; import app from "src/app"; import * as imageService from "src/services/imageService"; import request from "supertest"; afterEach(() => { jest.restoreAllMocks(); }) describe("endpoint returns the correct status codes", () => { it("should return 200 if successful", async () => { const res = await request(app).get("/image"); expect(res.status).toBe(200); }); it("should return 500 if any error happens", async () => { spyOn(imageService, "get").mockImplementation(() => { throw new Error("Controlled error") }); const res = await request(app).get("/image"); expect(res.status).toBe(500); }); });