title: Testing Promise.all with Jest/Vuex
body: <p>I am trying to test a Vuex action that uses Promise.all to fetch data from an API, and then commits a mutation based on the response. However, both my assertion test (<code>expect.assertions(1)</code>) and the test to see if the commit was called are failing.</p>
  
  <p>My action is: </p>
  
  <pre><code>fetchUserProfile ({ dispatch, commit}) {
        const userAccountFetch = api.get('/user/account');
        const userProfileFetch = api.get('/user/profile');
        const userItemsFetch = api.get(`/user/purchases`);
        Promise.all([
          userAccountFetch.catch((error) =&gt; {
            console.error(error);
            return { error, };
          }), 
          userProfileFetch.catch((error) =&gt; { 
            console.error(error); 
            return { error, };
          }),
          userItemsFetch.catch((error) =&gt; {
            console.error(error);
            return { error, };
          }),
        ]).then((responses) =&gt; {
            commit('setUserAccount', {responses});
          }
        });
    }
  </code></pre>
  
  <p>My test is as follows: </p>
  
  <pre><code>jest.mock('@api/api.js', () =&gt; ({ get: jest.fn(), }));
  const mockApi = require('@api/api.js');
  
  test('fetchUserProfile performs commit on successful fetch', () =&gt; {
      const mockResponse = [{userAccount: ....}, {userProfile: ...}, {userItems: ....}];
      mockApi.get.mockReturnValueOnce(Promise.resolve(mockResponse[0]));
      mockApi.get.mockReturnValueOnce(Promise.resolve(mockResponse[1]));
      mockApi.get.mockReturnValueOnce(Promise.resolve(mockResponse[2]));
      expect.assertions(1);
      fetchUserProfile({ commit, state, }).then(() =&gt; expect(commit).toHaveBeenCalledTimes(1));
    });
  </code></pre>
  
  <p>I put console.logs throughout my action, and the test is making it down to the line where I perform my commit, but for some reason the test is not passing.
  I'm not sure what is wrong here. Any help would be tremendously appreciate.</p>