How to use the @vue/test-utils.shallow function in @vue/test-utils

To help you get started, we’ve selected a few @vue/test-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github logaretm / vee-validate / tests / integration / snapshot.js View on Github external
test('snapshots should match', () => {
  const first = shallow(TestComponent, { localVue: Vue });
  const second = shallow(TestComponent, { localVue: Vue });

  // same component, no props, should match in UI and in HTML.
  expect(first.html()).toBe(second.html());
});
github Semantic-UI-Vue / Semantic-UI-Vue / test / specs / modules / Dropdown / Dropdown.spec.js View on Github external
it('should have icons, flags and images in selected options', () => {
    const wrapper = shallow(DropdownWithRequired, {
      propsData: {
        multiple: true,
        options: [
          {
            text: 'foo',
            value: 1,
            flag: 'cn',
            icon: 'question',
            image: {
              src: '/test',
            },
          },
        ],
      },
    });
github Semantic-UI-Vue / Semantic-UI-Vue / test / specs / elements / Header / Header.spec.js View on Github external
it('should have content', () => {
    const header1 = shallow(Header, { propsData: { content: 'Content String' } });
    expect(header1.text()).to.equal('Content String');

    const header2 = shallow(Header, { slots: { default: '<span>Content String</span>' } });
    expect(header2.text()).to.equal('Content String');
  });
});
github charliekassel / vuejs-datepicker / test / unit / specs / PickerDay / changeMonths.spec.js View on Github external
beforeEach(() => {
    wrapper = shallow(PickerDay, {
      propsData: {
        translation: en,
        allowedToShowView: () => true,
        selectedDate: new Date(2018, 2, 24),
        pageDate: new Date(2018, 1, 1)
      }
    })
  })
github MikaelEdebro / ezy-dev-session-jest / src / components / blog / __tests__ / BlogComments.spec.js View on Github external
return new Promise(resolve => {
          process.nextTick(() => {
            resolve([{ title: 'title 1' }, { title: 'title 2' }])
          })
        })
      })
    }
    store = new Vuex.Store({
      modules: {
        blog: {
          namespaced: true,
          actions
        }
      }
    })
    wrapper = shallow(BlogComments, {
      localVue,
      store,
      propsData: {
        id: 1
      },
      stubs: {
        Loader
      },
      mocks: {
        $texts: {
          noComments: 'No comments'
        }
      }
    })
    h = new TestHelpers(wrapper, expect)
  })
github mubaidr / vue-fluent / src / lib / components / switch / Switch.spec.js View on Github external
it('is called', () => {
    const wrapper = shallow(BSwitch)

    expect(wrapper.name()).toBe('BSwitch')
    expect(wrapper.isVueInstance()).toBeTruthy()
  })
})
github mubaidr / vue-fluent / src / lib / components / message / Message.spec.js View on Github external
it('is called', () => {
    const wrapper = shallow(BMessage)
    expect(wrapper.name()).toBe('BMessage')
    expect(wrapper.isVueInstance()).toBeTruthy()
  })
})
github mubaidr / vue-fluent / src / lib / components / input / Input.spec.js View on Github external
it('render the placeholder and readonly attribute when passed', () => {
    const wrapper = shallow(BInput, {
      attrs: { placeholder: 'Awesome!', readonly: true },
    })
    const target = wrapper.find('input')

    expect(target.element.getAttribute('placeholder')).toBe('Awesome!')
    expect(target.element.getAttribute('readonly')).toBe('readonly')
  })
github nsftx / chameleon-sdk / src / mixins / reactionable.spec.js View on Github external
reactionable,
  ],
  methods: {
    myAction(payload, data) {
      this.myActionResult = {
        payload,
        data,
      };
    },
  },
  render(h) {
    return h('div');
  },
};

const wrapper = shallow(component, {
  localVue,
  propsData: {
    definition: {
      type: 'panel',
      _id: 'MyPanel',
      _reactions: [
        {
          component: 'MyTable',
          componentType: 'table',
          event: 'MyTableEvent',
          listener: 'MyTable.MyTableEvent',
          action: 'myAction',
          schema: [{
            name: 'field',
            mapName: 'mapField',
          }],
github ulaval / modul-components / src / components / show-more / show-more.spec.ts View on Github external
const initializeShallowWrapper: any = () => {
    wrapper = shallow(MShowMore);

    wrapper.vm.$i18n.translate = jest.fn((key: string) => key);
};