// the find
posva/vue-router-mock
🧪 Easily mock routing interactions in your Vue apps
vue-router-mock lets you unit-test Vue 3 components that depend on vue-router without mounting a real router or writing end-to-end tests. It's for teams using Vitest or Jest who need to assert on pushes, params, and navigation guard behavior in isolation.
Written by the actual author of vue-router, so the mock API tracks the real router's behavior and TypeScript types closely instead of guessing at them from outside. setParams/setQuery/setHash let you change route state without triggering a full navigation, which keeps tests fast and deterministic. setNextGuardReturn gives explicit control over simulating a guard's redirect or block, and it auto-detects Jest/Vitest/Sinon to wire up spies without extra config.
Nested routes require manually setting router.depth.value to the right nesting level since the mock can't infer it, which is an easy thing to get wrong silently. RouterView and RouterLink are stubbed by default, so any test depending on actual nested view rendering needs manual overrides or it'll pass without exercising real composition. All navigation guards are ignored unless you opt into runInComponentGuards/runPerRouteGuards, so the default setup can give false confidence about guard-driven redirects. At 218 stars and one primary maintainer, it's a small surface area to bet a large test suite on if posva's priorities shift.