Skip to content

fix(test): resolve vi.mock hoisting failures on macOS runners#21500

Closed
irchelper wants to merge 2 commits intoopenclaw:mainfrom
irchelper:fix/macos-vi-mock-hoisting
Closed

fix(test): resolve vi.mock hoisting failures on macOS runners#21500
irchelper wants to merge 2 commits intoopenclaw:mainfrom
irchelper:fix/macos-vi-mock-hoisting

Conversation

@irchelper
Copy link
Copy Markdown

@irchelper irchelper commented Feb 20, 2026

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 Summary

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.

Confidence Score: 5/5

  • 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

Last reviewed commit: 8b6c3b6

@openclaw-barnacle openclaw-barnacle bot added channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord size: S labels Feb 20, 2026
@irchelper irchelper force-pushed the fix/macos-vi-mock-hoisting branch from bcba112 to 6e70be6 Compare February 22, 2026 13:20
@irchelper irchelper force-pushed the fix/macos-vi-mock-hoisting branch from 6e70be6 to d5021d5 Compare February 22, 2026 13:26
@irchelper irchelper force-pushed the fix/macos-vi-mock-hoisting branch 2 times, most recently from a269c87 to 5df98a6 Compare February 22, 2026 14:32
@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 28, 2026
@irchelper
Copy link
Copy Markdown
Author

Still relevant — CI green, ready for review.

@irchelper irchelper force-pushed the fix/macos-vi-mock-hoisting branch from 5df98a6 to c8821c7 Compare March 7, 2026 05:36
@irchelper irchelper force-pushed the fix/macos-vi-mock-hoisting branch from c8821c7 to 8d435b9 Compare March 11, 2026 02:17
@irchelper irchelper force-pushed the fix/macos-vi-mock-hoisting branch from 8d435b9 to c8821c7 Compare March 13, 2026 09:06
@irchelper irchelper force-pushed the fix/macos-vi-mock-hoisting branch from c8821c7 to 8e070ad Compare March 13, 2026 09:09
@openclaw-barnacle openclaw-barnacle bot added size: S and removed size: M stale Marked as stale due to inactivity labels Mar 13, 2026
@fabianwilliams fabianwilliams self-assigned this Mar 24, 2026
Copy link
Copy Markdown
Contributor

@fabianwilliams fabianwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix — the vi.hoisted() wraps in actions.test.ts and message-action-runner.test.ts look clean and match the existing codebase pattern.

Two questions on the other files:

extensions/bluebubbles/src/test-mocks.ts — The old code imported from the test harness (createBlueBubblesAccountsMockModule, createBlueBubblesProbeMockModule). The new code inlines the mock implementations directly. Was there a reason you couldn't wrap the existing harness imports with vi.hoisted() instead? Inlining means these mocks won't pick up future changes to the harness.

src/discord/monitor/exec-approvals.test.ts — Same pattern: the old mock used importOriginal to spread the real module and only override createDiscordClient. The new version replaces the entire module and manually reimplements stripUndefinedFields. If that module adds exports later, this mock would silently hide them. Could vi.hoisted() be applied to just the overridden functions while keeping importOriginal?

Happy to re-review once addressed — or if there's a reason the inlining is intentional, that context would be helpful. Thanks!

@steipete steipete added the r: no-ci-pr Auto-response for CI/test-failure PRs label Mar 30, 2026
@openclaw-barnacle
Copy link
Copy Markdown

Please don't make PRs for test failures on main.

The team is aware of those and will handle them directly on the codebase, not only fixing the tests but also investigating what the root cause is. Having to sift through test-fix-PRs (including some that have been out of date for weeks...) on top of that doesn't help. There are already way too many PRs for humans to manage; please don't make the flood worse.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord r: no-ci-pr Auto-response for CI/test-failure PRs size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants