You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These are some examples where hoisting works wrong:
import{jest}from'@jest/globals';jest.mock('some-module',()=>{constx=jest.requireActual('some-module');returnx;});// ⬇️⬇️⬇️_getJestObj().mock('some-module',()=>{constx=jest.requireActual('some-module');// should've been _getJestObj().requireActualreturnx;});function_getJestObj(){const{
jest
}=require("@jest/globals");_getJestObj=()=>jest;returnjest;}import{jest}from'@jest/globals';
import{jest}from'@jest/globals';jest.mock('some-module',()=>{constx=jest.requireActual('some-module');returnx;});// ⬇️⬇️⬇️_getJestObj().mock('some-module',()=>{constx=jest.fn();// should've been _getJestObj().fnreturn{
x
};});function_getJestObj(){const{
jest
}=require("@jest/globals");_getJestObj=()=>jest;returnjest;}import{jest}from'@jest/globals';
import{jest}from'@jest/globals';jest.mock('some-module',()=>({x: jest.fn()}));// ⬇️⬇️⬇️_getJestObj().mock('some-module',()=>({x: jest.fn()// should've been _getJestObj().fn}));function_getJestObj(){const{
jest
}=require("@jest/globals");_getJestObj=()=>jest;returnjest;}import{jest}from'@jest/globals';
Version
jest: 29.7.0
babel-preset-jest: 29.6.3
Steps to reproduce
These are some examples where hoisting works wrong:
Expected behavior
Expected correct hoisting.
Actual behavior
Wrong hoisting.
Additional context
No response
Environment
System: OS: macOS 15.2 CPU: (11) arm64 Apple M3 Pro Binaries: Node: 20.11.0 - /nix/store/yxjxfg053nbr6rqzcicifsvzab8aa072-nodejs-20.11.0/bin/node Yarn: 4.6.0 - /nix/store/7i5rhk1svf3b0hz6j5xf1rmy75s1l2l6-yarn-1.22.21/bin/yarn npm: 10.2.4 - /nix/store/yxjxfg053nbr6rqzcicifsvzab8aa072-nodejs-20.11.0/bin/npm npmPackages: jest: 29.7.0 => 29.7.0
The text was updated successfully, but these errors were encountered: