title: Testing vuex mocked mutation with jest
body: <p>I have been testing my vuex store with the following structure</p>
  
  <p><strong>/src/store.js</strong></p>
  
  <pre><code>import Vue from "vue";
  import Vuex from "vuex";
  
  Vue.use(Vuex);
  
  const state = {
    data: []
  };
  
  export const mutations = {
    SET_DATA(state, data) {
      state.data = data;
    }
  };
  
  export const actions = {
    fetchData({ commit }) {
      fetch("https://jsonplaceholder.typicode.com/users")
        .then(res =&gt; res.json())
        .then(data =&gt; commit(SET_DATA, data))
        .catch(err =&gt; console.log(err));
    }
  };
  
  export default new Vuex.Store({
    state,
    mutations,
    actions
  });
  </code></pre>
  
  <p>My test file for actions asserts for the url and commit triggering</p>
  
  <pre><code>it("should fetch correct data and commit to store", () =&gt; {
      // Mock fetch
      global.fetch = jest.fn().mockImplementationOnce(() =&gt;
        Promise.resolve({
          status: 200,
          json: () =&gt; Promise.resolve(JSON.stringify(mockData))
        })
      );
  
      return store.dispatch("fetchData").then(() =&gt; {
        expect(global.fetch).toHaveBeenCalledWith(
          "https://jsonplaceholder.typicode.com/users"
        );
        expect(mockSetData).toHaveBeenCalled();
      });
    });
  </code></pre>
  
  <p>Currently my test passes only for URL and does not call <code>mockSetData</code> which is a jest mocked function.</p>
  
  <p>I'm new to TDD and not quite sure why this fails. <a href="https://codesandbox.io/s/z27y95694x?previewwindow=tests" rel="nofollow noreferrer">Here's an implementation on codesandbox for more context</a> </p>