title: Jest.js tests don't pass when expected/received values are objects
body: <p>I'm testing this reducer:</p>
  <pre class="lang-js prettyprint-override"><code>const todo = (state = {}, action) =&gt; {
    switch(action.type) {
      case 'ADD_TODO':
        return {
          id: action.id,
          text: action.text,
          completed: false
        }
      case 'TOGGLE_TODO':
        if(state.id !== action.id) {
          return state;
        }
        return {...state, completed: !state.completed};
  
      default:
        return state;
    }
  }
  
  const todos = (state = [], action) =&gt; {
    switch(action.type) {
      case 'ADD_TODO':
        return [
          ...state,
          todo(undefined, action)
        ]
      case 'TOGGLE_TODO':
        return state.map(item =&gt; todo(item, action));
      default:
        return state;
    }
  }
  
  export default todos;
  </code></pre>
  <p>With this test:</p>
  <pre class="lang-js prettyprint-override"><code>import todos from './todos';
  
  test('creates a new todo', () =&gt; {
    const stateBefore = [];
    const action = {
      type: 'ADD_TODO',
      id: 0,
      text: 'test'
    };
    const stateAfter = [{
      id: 0,
      text: 'test',
      completed: false
    }];
  
    expect( JSON.stringify( todos(stateBefore, action) ) ).toBe( JSON.stringify(stateAfter) );
  });
  </code></pre>
  <p>The problem is that my tests fail with a <code>Compared values have no visual difference</code> remark if I remove the <code>JSON.stringify()</code> calls - I get that comparing an object to an object poses some problems because of reference, but do I have to use <code>JSON.stringify()</code> or loop through the object keys to compare them each time?</p>