#21500: fix(test): resolve vi.mock hoisting failures on macOS runners
channel: bluebubbles
channel: discord
size: S
Fix macOS-specific vi.mock hoisting failures (pre-existing, unrelated to any open feature PR).
On macOS Vitest runners, module-scope vi.fn() in vi.mock factories can be undefined after hoisting. Wrapping with vi.hoisted() ensures correct initialization order.
Files changed: actions.test.ts, media-send.test.ts, test-mocks.ts, feishu/media.test.ts, exec-approvals.test.ts, message-action-runner.test.ts
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Wraps module-scope `vi.fn()` calls in `vi.hoisted()` to fix macOS-specific Vitest hoisting failures where mocks could be undefined after hoisting. The changes update 4 test files to use the correct initialization order for mock factories.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no risk
- The changes are minimal, focused test-only fixes that follow established patterns used extensively throughout the codebase (172 other files use `vi.hoisted`). The fixes address a real macOS-specific testing issue without touching production code.
- No files require special attention
<sub>Last reviewed commit: 8b6c3b6</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#16479: fix(test): annotate vitest mock return types to resolve TS2742 port...
by colddonkey · 2026-02-14
78.8%
#17393: fix(ci): resolve TS2742 type error blocking all PRs
by miloudbelarebia · 2026-02-15
77.7%
#19063: CI/macOS: disable Vitest vmForks for TS tests to stop mock-state le...
by agisilaos · 2026-02-17
76.6%
#16544: refactor(test): structural MockFn for harness exports
by steipete · 2026-02-14
74.4%
#15569: test: comprehensive test coverage expansion (57 new test files)
by tangcruz · 2026-02-13
73.4%
#9333: Tests: add test coverage for security/audit-fs.ts
by M00N7682 · 2026-02-05
72.8%
#13848: fix(test): normalize paths in source-display test for windows
by gengmao · 2026-02-11
72.5%
#21027: fix(tests): resolve TypeScript type errors in CLI test files
by kittipond2365 · 2026-02-19
72.5%
#23594: test(tui): fix mock typing in command handler tests
by Sashamine · 2026-02-22
72.1%
#23480: fix(test): use path.join for cross-platform XDG path assertions in ...
by hydro13 · 2026-02-22
72.0%