- Prefer dependency injection over module mocking; define contracts in
common/src/types/contracts/. - Use
spyOn()only for globals / legacy seams. - Avoid
mock.module()for functions; use@codebuff/common/testing/mock-modules.tshelpers for constants only.
CLI hook testing note: React 19 + Bun + RTL renderHook() is unreliable; prefer integration tests via components for hook behavior.
For testing CLI behavior via tmux, use the helper scripts in scripts/tmux/. These handle bracketed paste mode and session logging automatically. Session data is saved to debug/tmux-sessions/ in YAML format and can be viewed with bun scripts/tmux/tmux-viewer/index.tsx. See scripts/tmux/README.md for details.