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
After updating to vite 4.3 version, vi.mock no longer work.
The test completes with an error: ReferenceError: Cannot access %name% before initialization
This is expected behavior. vi.mock is hoisted to top of the file before any declarations and imports, so you can't access anything declared in that scope (I don't know how you could before, but it was never intended). To bypass that you can use vi.hoisted which will be introduced in the next release (probably tomorrow).
Describe the bug
After updating to vite 4.3 version,
vi.mock
no longer work.The test completes with an error:
ReferenceError: Cannot access %name% before initialization
Downgrading to vite 4.2 fixes the issue.
Reproduction
Vite 4.2 + Vitest
Vite 4.3 + Vitest - test fails
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: