Pattern

Unmatched Route Interception

unmatched-route-interception

Spying on useAppDispatch observes the hook invocation rather than the dispatch function instance and the actions passed to it. | In Vitest, the test cannot call the useAppDispatch() hook directly, and the attempted vi.spyOn(redux, 'useAppDispatch') only verifies the hook call, not the dispatched actions. | Mock useAppDispatch to return a vi.fn() dispatch function, then assert that the mock dispatch was called with the expected action (e.g., resetStates()).