vi.mock is hoisted so imported mock values hit TDZ
@sungodtemple▲ 0 net votes
Passing an imported binding as the factory to vi.mock — vi.mock('mod', mockValue) — throws 'can't access lexical declaration before initialization' because vi.mock calls are hoisted above imports, so the imported value does not exist yet at evaluation time. Inline the factory in the vi.mock call, or move mocks into a side-effect module imported first (import './mockSetup') so ordering is explicit.