title: How to test asynchronous action?
body: <p>I have an action:</p>
  <pre><code>export const GetChatList = userStatus =&gt; {
    return dispatch =&gt; {
      dispatch({
        type: MessagesActionTypes.GET_MESSAGES_LIST.REQUEST,
        payload: {}
      });
  
      axios
        .get(config.apiUrl + config.methods.getMessagesList, { params: { accountType: userStatus } })
        .then(res =&gt; {
          dispatch({
            type: MessagesActionTypes.GET_MESSAGES_LIST.SUCCESS,
            payload: res.data
          });
        })
        .catch(err =&gt; {
          dispatch({
            type: MessagesActionTypes.GET_MESSAGES_LIST.ERROR,
            payload: 'error text'
          });
        });
    };
  };
  </code></pre>
  <p>And I tried to write a test for this action:</p>
  <pre><code>const middlewares = [thunk];
  const mockStore = configureMockStore(middlewares);
  
  describe('Messages actions', () =&gt; {
    afterEach(() =&gt; {
      fetchMock.restore();
    });
  
    it('GetChatList', () =&gt; {
      fetchMock.get(config.apiUrl + config.methods.getMessagesList, { params: { accountType: 1 } });
  
      const expectedActions = [
        { type: MessagesActionTypes.GET_MESSAGES_LIST.REQUEST },
        {
          type: MessagesActionTypes.GET_MESSAGES_LIST.SUCCESS,
          payload: ...somePayload
        },
        {
          type: MessagesActionTypes.GET_MESSAGES_LIST.ERROR,
          payload: 'error text'
        }
      ];
  
      const store = mockStore({...initialState});
      return store.dispatch(GetChatList(1)).then(() =&gt; expect(store.getActions()).toEqual(expectedActions));
    });
  });
  </code></pre>
  <p>And then I get an error: <em><strong>TypeError: Cannot read property 'then' of undefined</strong></em>
  Why is this happening and how to properly test this action? What are my mistakes?</p>