Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 787 Bytes

createLocalVue.md

File metadata and controls

28 lines (19 loc) · 787 Bytes

createLocalVue()

  • 戻り値:

    • {Component}
  • 使い方:

createLocalVue は、グローバル Vue クラスを汚染することなくコンポーネント、ミックスイン、プラグインを追加するための Vue クラスを返します。

options.localVue と一緒に使用してください。

import { createLocalVue, shallowMount } from '@vue/test-utils'
import Foo from './Foo.vue'

const localVue = createLocalVue()
const wrapper = shallowMount(Foo, {
  localVue,
  intercept: { foo: true }
})
expect(wrapper.vm.foo).toBe(true)

const freshWrapper = shallowMount(Foo)
expect(freshWrapper.vm.foo).toBe(false)