Skip to content

RouterLink.useLink is missing when using RouterLinkStub. #2069

Open
@rudolfbyker

Description

@rudolfbyker

Subject of the issue

RouterLink.useLink is missing when using RouterLinkStub.

Steps to reproduce

  1. Set up an empty project with Vite + Vitest + Vue3 + Vuetify3 + Vue Test Utils.
  2. Use VBtn with the to prop somewhere, e.g. MyComponent.vue:
    <template>
      <v-btn to="home">Home</v-btn>
    </template>
  3. Use RouterLinkStub in a test:
    // @vitest-environment jsdom
    
    import { mount, RouterLinkStub } from "@vue/test-utils";
    import { createVuetify } from "vuetify";
    import MyComponent from "./MyComponent.vue";
    
    test("MyComponent", async () => {
      mount(MyComponent, {
        global: {
          stubs: {
            RouterLink: RouterLinkStub,
          },
          plugins: [createVuetify()],
        },
      });
    });

Expected behaviour

MyComponent is mounted in the test, and VBtn works.

Actual behaviour

TypeError: RouterLink.useLink is not a function.

Possible Solution

Include the RouterLink.useLink function in the stub, since it seems to be part of the API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions