Vue test can't find store in child components

221 Views Asked by At

I have a parent component and there are several child components. Some children use Vuex store. When I try to mount parent component like below in Vue test, I'm getting an error "Cannot read state of undefined" in child components.

const store = new Vuex.Store({
    modules: {
      local: localStore
    },
  });

wrapper = mount(ParentComponent, {
      localVue,
      i18n,
      propsData,
      store,
      attachTo: document.body,
    });

I am sending a mock store in the mount. But it seems child component will not have access to it. How to mount a parent component with a child component that uses store?

0

There are 0 best solutions below