Closed
Description
What problem does this feature solve?
When adding tests to a component using the router, one might need to provide a mock router. I currently use:
const mockRouter = createRouter({ history: createWebHistory(), routes: [] });
describe('Navbar.vue', () => {
test('should ...', () => {
const navbar = mount(Navbar, {
global: {
plugins: [mockRouter],
stubs: {
RouterLink: RouterLinkStub
}
}
});
// ...
});
});
It works perfectly, but the router emits a warning:
console.warn node_modules/vue-router/dist/vue-router.cjs.js:225
[Vue Router warn]: No match found for location with path "/"
As most tests are using the same code, the warning is emitted a lot and pollutes the test output.
What does the proposed API look like?
Until VTU or the router itself provides built-in support for testing (if ever, see vuejs/test-utils#152 for curious readers), do you think we could guard this warning with a setting to hide it? I can open a PR if you provide some guidance (and think this is useful of course).