Skip to content

Instantly share code, notes, and snippets.

@lmiller1990
Last active April 23, 2021 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmiller1990/5eb1e4bbfc7b933b8bf1fad90e6d8517 to your computer and use it in GitHub Desktop.
Save lmiller1990/5eb1e4bbfc7b933b8bf1fad90e6d8517 to your computer and use it in GitHub Desktop.
mount.js
// test utils v1
import { mount as testUtilsMount, createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
// some function to create a new Vuex store with your state/mutations etc
// you want a fresh one for each test
import { createMyVuexStore } from './vuex-store'
export function mount(comp, options = {}, store) {
const localVue = createLocalVue()
localVue.use(Vuex)
// create a default one if not provided
if (!store) {
store = createMyVuexStore()
}
return testUtilsMount(comp, {...options, store})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment