How to mock a Vuex store in VueJS test-utils parentComponent
问题 I'm using Jest with vue-test-utils trying to test if a child component reacts to an $emit event in the parent component. VueJS test-utils library provides a parentComponent option to be passed when mounting/shallow mounting the component. Everything is working fine except that even though I instantiate the component with a mocked Vuex store, the parent component throws a TypeError: Cannot read property 'state' of undefined on a this.$store.state.something.here piece of code in the parent