From 1c737f1f938871e37fbc34450d2dcc0f36336e94 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 23 Feb 2021 15:59:17 -0700 Subject: [PATCH] refactor: hoist jest.mock in constants --- test/constants.test.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/constants.test.ts b/test/constants.test.ts index 4d4d327e2..7751ec53a 100644 --- a/test/constants.test.ts +++ b/test/constants.test.ts @@ -4,15 +4,11 @@ import { commit, getPackageJson, version } from "../src/node/constants" import { loggerModule } from "./helpers" +// jest.mock is hoisted above the imports so we must use `require` here. +jest.mock("@coder/logger", () => require("./helpers").loggerModule) + describe("constants", () => { describe("getPackageJson", () => { - // let spy: jest.SpyInstance - - beforeEach(() => { - // spy = jest.spyOn(logger, "warn") - jest.mock("@coder/logger", () => loggerModule) - }) - afterEach(() => { jest.clearAllMocks() })