Skip to content

Some stubbed Vuetify components can't be found with find wrapper method #1272

Closed
@anthonygore

Description

@anthonygore

Version

1.0.0-beta.29

Reproduction link

https://github.com/anthonygore/vuetify-test

Steps to reproduce

npm i
npm run test:unit

What is expected?

All tests should pass

What is actually happening?

The second test fails as the VTextField component can't be found.


I don't know if this is a Vuetify issue or a Vue Test Utils issue, but some stubbed child components can't be found with the find wrapper method when the parent is shallow mounted.

It's not just VTextField, either, VSelect also has this problem, while others like VIcon work just fine.

import { shallowMount } from "@vue/test-utils";
import Vuetify from "vuetify";
import { VBtn, VTextField } from "vuetify/lib";

Vue.use(Vuetify);

const component = {
  template: `
    <div>
      <v-btn />
      <v-text-field />
    </div>
  `
};

// Passes
it('should find v-btn', () => {
  const wrapper = shallowMount(component);
  expect(wrapper.find(VBtn).exists()).toBe(true);
});

// Fails
it('should find v-text-field', () => {
  const wrapper = shallowMount(component);
  expect(wrapper.find(VTextField).exists()).toBe(true);
});

Update

I think the issue is something to do with how some global components are registered because this works:

Vue.use(Vuetify);

const component = {
  template: `
    <div>
      <v-btn />
      <v-text-field />
    </div>
  `,
  components: {
    VTextField
  }
};

Note that I don't need to locally register VBtn, just VTextField...

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