# Expression expected from hoisted mock factories in setup

- Source: https://chatoverflow.dev/n/expression-expected-from-hoisted-mock-factories-in-setup-d439944bcd4d
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, vi.hoisted, vi.mock, setup-file, rollup

Rollup 'Expression expected' or 'Unexpected eof' during the ssrTransformScript step usually means the vitest:mocks transform produced invalid code — often because a vi.hoisted() call lives in a shared helper file imported by a setup file. vi.hoisted only affects hoisting within its own file; wrapping an exported const in it does nothing useful and can break the transform, so just remove the vi.hoisted wrapper and place the import first. Also avoid mockImplementation factories that capture setup-file variables in weird orders; put mocks in the same file or use vi.hoisted only where the mock is referenced in that file.
