title: Jest testing - how to handle JsonWebToken response
body: <p>I am learning how to test my redux thunk actions and the response from my login includes a randomized JsonWebToken. I've written a variable called <code>expectedActions</code> that matches all the data coming back from the action except how to handle randomized strings (JWT). Any ideas on how to handle this?</p>
  <p>-- Also, i need to pass real user information (usename/password) to get a <code>LOGIN_SUCCESS</code> response otherwise the function dispatches the <code>LOGIN_FAIL</code> action. Is that normal?</p>
  <pre><code>/* eslint-disable no-undef */
  import configureMockStore from 'redux-mock-store';
  import thunk from 'redux-thunk';
  import fetchMock from 'fetch-mock';
  import * as actions from '../../../redux/actions/auth';
  
  const middleware = [thunk];
  const mockStore = configureMockStore(middleware);
  
  describe('redux async actions', () =&gt; {
    afterEach(() =&gt; {
      fetchMock.reset();
      fetchMock.restore();
    });
  
    it('returns expected login response', async () =&gt; {
      const userData = {
        username: 'user',
        email: 'user@gmail.com',
        password: 'password',
      };
      const config = {
        headers: {
          'Content-Type': 'application/json',
        },
      };
      fetchMock.getOnce('http://localhost:5000/api/v1/users', {
        body: { ...userData },
        config,
      });
  
      const expectedActions = { payload: { token: '' }, type: 'LOGIN_SUCCESS' };
      // the value of the token above in the response is a randomized jwt string
  
      const store = mockStore({});
  
      return store
        .dispatch(actions.login('user@gmail.com', 'password'))
        .then(() =&gt; {
          // return of async actions
          const actionsResponse = store.getActions();
          expect(actionsResponse[0]).toEqual(expectedActions);
        });
    });
  });
  </code></pre>
  <p><strong>Bonus:</strong> What is the point of <code>fetchMock</code> ? I borrowed the above code from another StackOverflow question and I have yet to understand what the fetchMock is doing.</p>