typezero
Version:
Zero-config TypeScript starter for modern Node.js development. ESM, Biome, Vitest. Production-ready in seconds! ⚡
28 lines • 1.02 kB
JavaScript
import { main } from "./index.js";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
describe("Application", () => {
beforeAll(() => {
vi.spyOn(console, "log").mockImplementation(() => { });
vi.spyOn(console, "error").mockImplementation(() => { });
vi.spyOn(process, "exit").mockImplementation(() => undefined);
});
afterAll(() => {
vi.restoreAllMocks();
});
it("should handle SIGINT signal", () => {
process.emit("SIGINT");
expect(process.exit).toHaveBeenCalledWith(0);
});
it("should start successfully", () => {
main();
expect(console.log).toHaveBeenCalledWith(expect.stringContaining("Party time!"));
});
it("should handle errors gracefully", () => {
vi.mocked(console.log).mockImplementationOnce(() => {
throw new Error("Startup error");
});
main();
expect(process.exit).toHaveBeenCalledWith(1);
});
});
//# sourceMappingURL=index.test.js.map