27 lines
718 B
TypeScript
27 lines
718 B
TypeScript
|
import { randomUUID } from "crypto";
|
||
|
|
||
|
jest.spyOn(console, "log");
|
||
|
jest.mock("typeorm");
|
||
|
|
||
|
describe("index", () => {
|
||
|
beforeEach(() => {
|
||
|
jest.clearAllMocks();
|
||
|
|
||
|
process.env["DB_HOST"] = randomUUID();
|
||
|
process.env["DB_USER"] = randomUUID();
|
||
|
process.env["DB_PASS"] = randomUUID();
|
||
|
process.env["DB_NAME"] = randomUUID();
|
||
|
});
|
||
|
|
||
|
it("should log hello world", async () => {
|
||
|
(console.log as jest.MockedFn<typeof console.log>).mockImplementation(() => {
|
||
|
return;
|
||
|
});
|
||
|
|
||
|
await (await import("./index")).default;
|
||
|
|
||
|
expect(console.log).toHaveBeenCalledTimes(1);
|
||
|
expect(console.log).toHaveBeenLastCalledWith("Hello world!");
|
||
|
});
|
||
|
});
|