@oarepo/oarepo-ui-vue
Version:
Base Vue UI Components for OA Repository
38 lines (29 loc) • 1.06 kB
JavaScript
import Vue from 'vue'
import vueTestUtils from '@vue/test-utils'
// ===
// Configure Vue
// ===
// Don't warn about not using the production build of Vue, as
// we care more about the quality of errors than performance
// for tests.
Vue.config.productionTip = false
// ===
// Global helpers
// ===
// https://vue-test-utils.vuejs.org/api/#mount
global.mount = vueTestUtils.mount
// https://vue-test-utils.vuejs.org/api/#shallowmount
global.shallowMount = vueTestUtils.shallowMount
// A helper for creating Vue component mocks
global.createComponentMocks = ({ mocks, stubs }) => {
// Use a local version of Vue, to avoid polluting the global
// Vue and thereby affecting other tests.
// https://vue-test-utils.vuejs.org/api/#createlocalvue
const localVue = vueTestUtils.createLocalVue()
const returnOptions = { localVue }
// https://vue-test-utils.vuejs.org/api/options.html#stubs
returnOptions.stubs = stubs || {}
// https://vue-test-utils.vuejs.org/api/options.html#mocks
returnOptions.mocks = mocks || {}
return returnOptions
}