You only need to stub it in the component where you're using router-link. Just ran into this warning and seems not well documented it can be solved like so:
import { mount, RouterLinkStub } from "@vue/test-utils";
import { describe, expect, it } from "vitest";
import SomeComponent from "@/components/SomeComponent.vue";
describe("SomeComponent tests", () => {
it("Renders my component with links in it", () => {
const some_comp = mount(SomeComponent, {
props: {
label: "some text",
link: "/some/url/here",
},
global: {
stubs: {
"router-link": RouterLinkStub,
},
},
});
// it renders and we check the link is set:
expect(some_comp.text()).toContain("some text");
const link_component = some_comp.findComponent(RouterLinkStub);
expect(link_component.props().to).toBe("/some/url/here");
});
});