From e6a324b48410b33471fc874f97efa85cd7380c57 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 23 Feb 2021 16:11:04 -0700 Subject: [PATCH] refactor: update mocking logger in register test --- test/register.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/register.test.ts b/test/register.test.ts index 6ae30376..dc024697 100644 --- a/test/register.test.ts +++ b/test/register.test.ts @@ -1,6 +1,9 @@ import { JSDOM } from "jsdom" 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("register", () => { const { window } = new JSDOM() global.window = (window as unknown) as Window & typeof globalThis @@ -18,10 +21,6 @@ describe("register", () => { }) }) - beforeEach(() => { - jest.mock("@coder/logger", () => loggerModule) - }) - afterEach(() => { mockRegisterFn.mockClear() jest.resetModules()