Skip to content

fix: hoist backend vitest mocks to module scope (@LekhanaMitta) - #8323

Open
LekhanaMitta wants to merge 1 commit into
monkeytypegame:masterfrom
LekhanaMitta:fix/backend-vitest-mocks
Open

fix: hoist backend vitest mocks to module scope (@LekhanaMitta)#8323
LekhanaMitta wants to merge 1 commit into
monkeytypegame:masterfrom
LekhanaMitta:fix/backend-vitest-mocks

Conversation

@LekhanaMitta

Copy link
Copy Markdown

This PR fixes a backend test setup issue by hoisting the Vitest mock registrations to module scope.

The backend test files were calling vi.mock(...) from helper/setup functions during beforeAll. Vitest hoists vi.mock calls, so placing them inside runtime setup can lead to incorrect module resolution order and unstable worker execution. I moved these mocks to the top level of the setup modules so they are registered in the expected order before the tests run.

This keeps the backend test harness aligned with Vitest’s mock semantics and prevents the worker instability that was appearing during the backend integration run.

Verified with:

pnpm test-be

This passes after the change.

@monkeytypegeorge monkeytypegeorge added the backend Server stuff label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants