-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
🐛 Bug Report
When attempting to use jest.*
within a jest.mock
function, jest fails due to the variable jest
being used as an out-of-scope variable.
To Reproduce
The following code fails with:
The module factory of
jest.mock()
is not allowed to reference any out-of-scope variables.
Invalid variable access: jest
import { jest } from '@globals/jest';
jest.mock('module', () => {
const originalModule = jest.requireActual('module');
return {
__esModule: true,
...originalModule,
method: jest.fn(),
}
});
Expected behavior
Expect jest to be a whitelisted object for scoped-variables within mocks.
Link to repl or repo (highly encouraged)
None.
envinfo
Binaries:
Node: 14.4.0
Yarn: 1.22.4
npm: 6.14.5
michael-wolfenden, cprass, MrWook, tschut, matthew1000 and 5 more