title: `TypeError: store.dispatch(...).then is not a function` when trying to test async actions
body: <p>Trying to test my async action creators using this example: <a href="http://redux.js.org/docs/recipes/WritingTests.html#async-action-creators" rel="nofollow noreferrer">http://redux.js.org/docs/recipes/WritingTests.html#async-action-creators</a> and I think I did everything the same but I've got an error:</p>
  
  <pre><code>async actions › creates FETCH_BALANCE_SUCCEESS when fetching balance has been done
  
      TypeError: store.dispatch(...).then is not a function
  </code></pre>
  
  <p>Don't understand why it's happened because I did everything from the example step by step. </p>
  
  <p>I also found this example <a href="http://arnaudbenard.com/redux-mock-store/" rel="nofollow noreferrer">http://arnaudbenard.com/redux-mock-store/</a> but anyway, mistake exists somewhere and unfortunately, I can't find it. Where is my mistake, why I've got an error even If my test case looks like the same as an example </p>
  
  <p>My test case:</p>
  
  <pre><code>import nock from 'nock';
  import configureMockStore from 'redux-mock-store';
  import thunk from 'redux-thunk';
  import * as actions from './';
  import * as types from '../constants';
  
  const middlewares = [thunk];
  const mockStore = configureMockStore(middlewares);
  
  describe('async actions', () =&gt; {
    afterEach(() =&gt; {
      nock.cleanAll();
    });
  
    it('creates FETCH_BALANCE_SUCCEESS when fetching balance has been done', () =&gt; {
      const store = mockStore({});
  
      const balance = {};
  
      nock('http://localhost:8080')
        .get('/api/getbalance')
        .reply(200, { body: { balance } });
  
      const expectedActions = [
        { type: types.FETCH_BALANCE_REQUEST },
        { type: types.FETCH_BALANCE_SUCCEESS, body: { balance } },
      ];
  
      return store.dispatch(actions.fetchBalanceRequest()).then(() =&gt; {
        // return of async actions
        expect(store.getActions()).toEqual(expectedActions);
      });
    });
  });
  </code></pre>
  
  <p>My actions which I am trying to test.</p>
  
  <pre><code>import 'whatwg-fetch';
  import * as actions from './actions';
  import * as types from '../constants';
  
  export const fetchBalanceRequest = () =&gt; ({
    type: types.FETCH_BALANCE_REQUEST,
  });
  
  export const fetchBalanceSucceess = balance =&gt; ({
    type: types.FETCH_BALANCE_SUCCEESS,
    balance,
  });
  
  export const fetchBalanceFail = error =&gt; ({
    type: types.FETCH_BALANCE_FAIL,
    error,
  });
  
  
  const API_ROOT = 'http://localhost:8080';
  
  const callApi = url =&gt;
    fetch(url).then(response =&gt; {
      if (!response.ok) {
        return Promise.reject(response.statusText);
      }
      return response.json();
    });
  
  export const fetchBalance = () =&gt; {
    return dispatch =&gt; {
      dispatch(actions.fetchBalanceRequest());
      return callApi(`${API_ROOT}/api/getbalance`)
        .then(json =&gt; dispatch(actions.fetchBalanceSucceess(json)))
        .catch(error =&gt;
          dispatch(actions.fetchBalanceFail(error.message || error))
        );
    };
  };
  </code></pre>