Buefy error when testing with jest - vuejs

Viewed 107

Im geting this error:

    [Vue warn]: Unknown custom element: <b-taginput> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

on this test:

import MultipleChoice from '@/components/MultipleChoice';
import Buefy from 'buefy';

const localVue = createLocalVue();
localVue.use(Buefy);


describe('MultipleChoice.vue', () => {
  let wrapper;
  beforeEach(() => {
    wrapper = shallowMount(MultipleChoice, {
      propsData: {
        choices: ['en', 'de', 'it'],
      }
    });
  });

  test('renders correctly', () => {
    expect(wrapper).toMatchSnapshot();
  });
});

the test itself passes, but this warning keeps showing up.

This is my component:

  <b-taginput
    v-model="value"
    :data="filteredData"
    expanded
    autocomplete
    open-on-focus
    clear-on-select
    field="display_name"
    icon="label"
    @input="update()" />

does anybody knows what is going on?

1 Answers

I figured it out. What was missing:

import MultipleChoice from '@/components/MultipleChoice';
import Buefy from 'buefy';

const localVue = createLocalVue();
localVue.use(Buefy);


describe('MultipleChoice.vue', () => {
  let wrapper;
  beforeEach(() => {
    wrapper = shallowMount(MultipleChoice, {
      propsData: {
        choices: ['en', 'de', 'it'],
      },
      stubs: {
        transition: false,
        'b-taginput': true
      }
    });
  });

  test('renders correctly', () => {
    expect(wrapper).toMatchSnapshot();
  });
});
Related