How to use the @vue/test-utils.shallowMount 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 tianyong90 / we-vue / test / unit / specs / input.spec.js View on Github external
methods: {
        validate: validateSpy
      }
    })

    wrapper.find('input').element.value = 'test'
    wrapper.find('input').trigger('input')

    expect(wrapper.vm.currentValue).toBe('test')
    expect(validateSpy).toHaveBeenCalled()

    // reset the spy states
    validateSpy.mockClear()

    // do not validate on input
    wrapper = shallowMount(Input, {
      propsData: {
        validateMode: {
          onInput: false
        }
      },
      methods: {
        validate: validateSpy
      }
    })

    wrapper.find('input').element.value = 'test'
    wrapper.find('input').trigger('input')

    expect(validateSpy).not.toHaveBeenCalled()
  })
github tianyong90 / we-vue / packages / we-vue / src / components / WBadge / __test__ / WBadge.spec.ts View on Github external
test('create', () => {
    const wrapper = shallowMount(Badge, {
      propsData: {},
    })

    expect(wrapper.classes()).toContain('weui-badge')
    expect(wrapper.html()).toMatchSnapshot()
  })
github sagalbot / vue-select / tests / unit / Reduce.spec.js View on Github external
it("can determine if an object is pre-selected", () => {
    const Select = shallowMount(VueSelect, {
      propsData: {
        reduce: option => option.id,
        value: "foo",
        options: [
          {
            id: "foo",
            label: "This is Foo"
          }
        ]
      }
    });

    expect(
      Select.vm.isOptionSelected({
        id: "foo",
        label: "This is Foo"
github dumptyd / vue-css-donut-chart / tests / unit / donut.spec.js View on Github external
it('throws an error if sum of the section values exceed total', () => {
      const spy = jest.spyOn(global.console, 'error').mockImplementation(() => {});

      const [total, sections] = [50, [{ value: 25 }, { value: 26 }]];

      let errorThrown = false;
      try {
        shallowMount(Donut, { propsData: { total, sections } });
      }
      catch (error) {
        errorThrown = true;
        expect(error.message).toContain('should not exceed');
      }
      finally {
        expect(errorThrown).toBe(true);
        spy.mockRestore();
      }
    });
  });
github morkro / happy-plants / test / unit / specs / components / Modal.spec.js View on Github external
it('is a Vue component', () => {
    const wrapper = shallowMount(Modal)
    expect(wrapper.isVueInstance()).toBe(true)
  })
github luniehq / lunie / tests / unit / specs / components / governance / PageProposals.spec.js View on Github external
loading: false,
          error: undefined
        },
        parameters: {
          loading: false,
          error: undefined
        }
      }
    }
    const args = {
      mocks: {
        $store,
        $apollo
      }
    }
    wrapper = shallowMount(PageProposals, args)
  })
github morkro / happy-plants / src / app / plant / components / PlantTags.spec.js View on Github external
it('has correct default props data', () => {
    const wrapper = shallowMount(PlantTags, options)
    expect(wrapper.props().tags).toEqual([])
  })
github gitlabhq / gitlabhq / spec / frontend / projects / experiment_new_project_creation / components / app_spec.js View on Github external
const createComponent = (propsData) => {
    wrapper = shallowMount(App, { propsData });
  };
github gitlabhq / gitlabhq / spec / frontend / issue_show / components / form_spec.js View on Github external
const createComponent = (props) => {
    wrapper = shallowMount(formComponent, {
      propsData: {
        ...defaultProps,
        ...props,
      },
    });
  };
github gitlabhq / gitlabhq / spec / frontend / monitoring / components / dashboard_panel_spec.js View on Github external
beforeEach(() => {
      wrapper = shallowMount(DashboardPanel, {
        propsData: {
          clipboardText: exampleText,
          settingsPath: dashboardProps.settingsPath,
          graphData: {
            y_label: 'metric',
            ...graphData,
          },
        },
        store,
      });
      return wrapper.vm.$nextTick();
    });