Skip to content

Commit

Permalink
chore: remove unused exports in jest.mock.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ChALkeR committed Sep 10, 2024
1 parent 075e6b5 commit 3bbeb6e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/jest.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const jestModuleMocks = {
resetModules,
}

export function resolveModule(name) {
function resolveModule(name) {
assert(requireIsRelative || /^[@a-zA-Z]/u.test(name), 'Mocking relative paths is not possible')
const unprefixed = name.replace(/^node:/, '')
if (builtinModules.includes(unprefixed)) return unprefixed
Expand All @@ -49,20 +49,20 @@ function resolveImport(name) {
}
}

export function requireActual(name) {
function requireActual(name) {
const resolved = resolveModule(name)
if (mapActual.has(resolved)) return mapActual.get(resolved)
if (!mapMocks.has(resolved)) return require(resolved)
throw new Error('Module can not been loaded')
}

export function requireMock(name) {
function requireMock(name) {
const resolved = resolveModule(name)
assert(mapMocks.has(resolved), 'Module is not mocked')
return mapMocks.get(resolved)
}

export function resetModules() {
function resetModules() {
for (const [, ctx] of nodeMocks) {
if (mock.module) ctx.restore()
}
Expand Down Expand Up @@ -181,7 +181,7 @@ function mockCloneItem(obj, cache) {
return null
}

export function jestmock(name, mocker, { override = false } = {}) {
function jestmock(name, mocker, { override = false } = {}) {
assert(process.env.EXODUS_TEST_ENVIRONMENT !== 'bundle', 'module mocks unsupported from bundle') // TODO: can we do something?

// Loaded ESM: isn't mocked
Expand Down

0 comments on commit 3bbeb6e

Please sign in to comment.