Skip to content

Commit c883702

Browse files
committed
refactor: hoist jest.mock in constants
1 parent dde96c4 commit c883702

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

test/constants.test.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
import { commit, getPackageJson, version } from "../src/node/constants"
55
import { loggerModule } from "./helpers"
66

7+
// jest.mock is hoisted above the imports so we must use `require` here.
8+
jest.mock("@coder/logger", () => require("./helpers").loggerModule)
9+
710
describe("constants", () => {
811
describe("getPackageJson", () => {
9-
// let spy: jest.SpyInstance
10-
11-
beforeEach(() => {
12-
// spy = jest.spyOn(logger, "warn")
13-
jest.mock("@coder/logger", () => loggerModule)
14-
})
15-
1612
afterEach(() => {
1713
jest.clearAllMocks()
1814
})

0 commit comments

Comments
 (0)