Testing Vuex in components

  • how to mock Vuex
const wrapper = shallowMount(Foo, {
  mocks: {
    $store: {
      state: {}
    }
  }
})
  • Talk about using localVue.use(Vuex) to test
localVue.use(Vuex)
const store = new Vuex.Store({})

const wrapper = shallowMount(Foo, {
  store
  localVue
})
更新: 7/25/2018, 7:33:15 PM