Home Testing async actions with redux thunk
 I am trying to test my action which has an async call. I use Thunk as my middleware. In the action below, I only dispatch and update the store if the server returns an OK response. export const SET_SUBSCRIBED = 'SET_SUBSCRIBED' export const setSubscribed = (subscribed) => { return function(dispatch) { var url = 'https://api.github.com/users/1/repos'; return fetch(url, {method: 'GET'}) .then(function(result) { if (result.status === 200) { dispatch({ type: SET_SUBSCRIBED, subscribed: subscribed }) return 'result' } return 'failed' //todo }, function(error) { return 'error' }) } }  I am having trouble writing tests to either tests that dispatch either gets called or doesn't (depending on server response) or I could just let the action get called and check that the value in the store is updated correctly. I am using fetch-mock to mock the web's fetch() implementation. However, it looks like the block of my code in then does not execute. I have also tried using the example here with no luck - http://redux.js.org/docs/recipes/WritingTests.html const middlewares = [ thunk ] const mockStore = configureStore(middlewares) //passing test it('returns SET_SUBSCRIBED type and subscribed true', () => { fetchMock.get('https://api.github.com/users/1/repos', { status: 200 }) const subscribed = { type: 'SET_SUBSCRIBED', subscribed: true } const store = mockStore({}) store.dispatch(subscribed) const actions = store.getActions() expect(actions).toEqual([subscribed]) fetchMock.restore() }) //failing test it('does nothing', () => { fetchMock.get('https://api.github.com/users/1/repos', { status: 400 }) const subscribed = { type: 'SET_SUBSCRIBED', subscribed: true } const store = mockStore({}) store.dispatch(subscribed) const actions = store.getActions() expect(actions).toEqual([]) fetchMock.restore() })  After looking into this some more, I believe there is something wrong with fetch-mock either not resolving the promise so that the then statements execute or it's completely stubbing out fetch. When I add a console.log to both then statements, nothing executes. What am I doing incorrectly in my tests?