title: jest mock vuex useStore() with vue 3 composition api
body: <p>I'm trying to unit test a component where you click a button which should then call store.dispatch('favoritesState/deleteFavorite').</p>
  <p>This action then calls an api and does it's thing. I don't want to test the implementation of the vuex store, just that the vuex action is called when you click the button in the component.</p>
  <p><strong>The Component looks like this</strong></p>
  <pre><code>&lt;template&gt;
      &lt;ion-item :id=&quot;favorite.key&quot;&gt;
          &lt;ion-thumbnail class=&quot;clickable-item remove-favorite-item&quot; @click=&quot;removeFavorite()&quot; slot=&quot;end&quot; id=&quot;favorite-star-thumbnail&quot;&gt;           
          &lt;/ion-thumbnail&gt;
      &lt;/ion-item&gt;
  &lt;/template&gt;
  
  import {useStore} from &quot;@/store&quot;;
  export default defineComponent({
       setup(props) {
          const store = useStore();
      
          function removeFavorite() {
              store.dispatch(&quot;favoritesState/deleteFavorite&quot;, props.item.id);
          }
  
          return {
              removeFavorite,
          }
       }
  });
  </code></pre>
  <p><strong>The jest test</strong></p>
  <pre><code>import {store} from &quot;@/store&quot;;
  
  test(`${index}) Test remove favorite for : ${mockItemObj.kind}`, async () =&gt; {
  
      const wrapper = mount(FavoriteItem, {
          propsData: {
              favorite: mockItemObj
          },
          global: {
              plugins: [store]
          }
      });
      const spyDispatch = jest.spyOn(store, 'dispatch').mockImplementation();
  
      await wrapper.find('.remove-favorite-item').trigger('click');
      expect(spyDispatch).toHaveBeenCalledTimes(1);
  });
  </code></pre>
  <p>I have tried different solutions with the same outcome. Whenever the &quot;trigger('click')&quot; is run it throws this error:</p>
  <blockquote>
  <p>Cannot read properties of undefined (reading 'dispatch') TypeError:
  Cannot read properties of undefined (reading 'dispatch')</p>
  </blockquote>
  <p>The project is written in vue3 with typescript using composition API and vuex4</p>