## Lesson — Use global mock restoration for Vitest spies

**Tags:** testing, typescript
**Scope:** packages/**/*.test.ts

Use vi.restoreAllMocks() in afterEach when spying on globals, as Vitest's spy return types often fail to narrow cleanly in strict TypeScript environments.
