title: Why is my jest async action creator test not working?
body: <p>I am very new to unit testing, and am trying to go through my react-redux project to write some tests. </p>
  
  <p>Why is this test not working, and how could I make it pass? </p>
  
  <p>Here is the test. I want to test my fetch posts action creator. This is for a small blog application.:</p>
  
  <pre><code>import configureStore from 'redux-mock-store'; // ES6 modules
  import { findSinglePost, sendEdit, changeRedirect, checkBoxChange } from '../client/redux/actions/postActions';
  import thunk from 'redux-thunk';
  import axios from 'axios';
  
  const middlewares = [thunk];
  const mockStore = configureStore(middlewares);
  describe('asynchronous action creators', () =&gt; {
  
    it('should fetch posts', () =&gt; {
      let store = mockStore({})
  
      //my async action creator. It uses mock data that's in the same folder.
      const fetchPosts = () =&gt; function(dispatch) {
        dispatch({type: 'FETCH_POSTS'});
  
        return axios.get('./MOCK.json').then((response) =&gt; {
          dispatch({type: 'FETCH_POSTS_FUFILLED', payload: response.data});
        }).catch((err) =&gt; {
          dispatch({type: 'FETCH_POSTS_REJECTED', payload: err});
        });
      };
      //this doesn't equal FETCH_POSTS_FUFILLED, it ends up equaling just "FETCH_POSTS"
      return store.dispatch(fetchPosts()).then(() =&gt; {
        const actions = store.getActions();
        expect(actions[0]).toEqual({type: 'FETCH_POSTS_FUFILLED'});
      })
    })
  });
  </code></pre>
  
  <p>Here is jest's feedback. I want it to equal 'FETCH_POSTS_'FUFILLED', but it's returning 'FETCH_POSTS'. :</p>
  
  <pre><code> FAIL  _test_\actions.test.js
    ● asynchronous action creators › should fetch posts
  
      expect(received).toEqual(expected)
  
      Expected value to equal:
        {"type": "FETCH_POSTS_FUFILLED"}
      Received:
        {"type": "FETCH_POSTS"}
  
      Difference:
  
      - Expected
      + Received
  
        Object {
      -   "type": "FETCH_POSTS_FUFILLED",
      +   "type": "FETCH_POSTS",
        }
  
        88 |     return store.dispatch(fetchPosts()).then(() =&gt; {
        89 |       const actions = store.getActions();
      &gt; 90 |       expect(actions[0]).toEqual({type: 'FETCH_POSTS_FUFILLED'});
        91 |     })
        92 |   })
        93 | });
  
        at _test_/actions.test.js:90:26
  
   PASS  client\views\LoginPage\LoginPage.test.jsx
  
  Test Suites: 1 failed, 1 passed, 2 total
  Tests:       1 failed, 5 passed, 6 total
  Snapshots:   0 total
  Time:        1.49s
  Ran all test suites related to changed files.
  </code></pre>
  
  <p>Also, here is the project's github <a href="https://github.com/capozzic1/react-blog" rel="nofollow noreferrer">repo</a> if you want to try to run it.</p>
  
  <p>Also, if there's a standard way in the industry that's more well known on how to do this, I'd love the advice. </p>
  
  <p>Edit: </p>
  
  <p>When I change actions[0] to <strong>actions[ 1]</strong> I get this error: </p>
  
  <pre><code>Expected value to equal:
    {"type": "FETCH_POSTS_FUFILLED"}
  Received:
    {"payload": {Symbol(impl): {"message": "The string did not match the expected pattern.", "name": "SyntaxError", Symbol(wrapper): [Circular]}}, "type": "FETCH_POSTS_REJECTED"}
  
  Difference:
  
  - Expected
  + Received
  
    Object {
  -   "type": "FETCH_POSTS_FUFILLED",
  +   "payload": DOMException {
  +     Symbol(impl): DOMExceptionImpl {
  +       "message": "The string did not match the expected pattern.",
  +       "name": "SyntaxError",
  +       Symbol(wrapper): [Circular],
  +     },
  +   },
  +   "type": "FETCH_POSTS_REJECTED",
  </code></pre>
  
  <p>Here is the picture form of jest's feedback:
  <a href="https://i.stack.imgur.com/Lypjg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lypjg.png" alt=""></a></p>