refactor: hoist jest.mock in constants

This commit is contained in:
Joe Previte 2021-02-23 15:59:17 -07:00
parent 1470ff203a
commit 1c737f1f93
No known key found for this signature in database
GPG Key ID: 2C91590C6B742C24
1 changed files with 3 additions and 7 deletions

View File

@ -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()
})