Last active
May 5, 2019 01:58
-
-
Save achhunna/1e379a05197aa980db967ac1616b3638 to your computer and use it in GitHub Desktop.
Jest test template with Vuex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallowMount, createLocalVue } from '@vue/test-utils'; | |
import Vuex from 'vuex'; | |
import Component from './component'; | |
let wrapper; | |
let store; | |
let actions; | |
let mutations; | |
let state; | |
const localVue = createLocalVue(); | |
localVue.use(Vuex); | |
beforeEach(() => { | |
actions = { | |
someAction: jest.fn() | |
}; | |
mutations = { | |
someMutation: jest.fn() | |
}; | |
state = { | |
key: {} | |
}; | |
store = new Vuex.Store({ | |
actions, | |
mutations, | |
state, | |
}); | |
wrapper = shallowMount(Component, { | |
propsData: {}, | |
mocks: {}, | |
stubs: {}, | |
methods: {}, | |
store, | |
localVue, | |
}); | |
}); | |
afterEach(() => { | |
wrapper.destroy(); | |
}); | |
describe('Component', () => { | |
test('is a Vue instance', () => { | |
expect(wrapper.isVueInstance).toBeTruthy(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment