Vue · Senior · Question 47 of 75
How do you test a component that uses Vue Router?
- ✓Correct answer: Install a real router with
createMemoryHistoryin the test, navigate, andawait router.isReady() - 2Mock
window.location - 3Routing can't be tested in unit tests
Explanation
Memory history works in Node. Alternatively stub RouterLink and mock useRoute for isolated tests; real routers catch more integration bugs.