title: Trouble testing button onClick handler with Enzyme
body: <p>I am having trouble using Enzyme's contains method when it comes to a button's onClick handler where the provided action method requires an argument.
    I ran into this while passing redux actions to a component, but I'll use simplified examples here.</p>
  
  <p>Say you have two methods:</p>
  
  <pre><code>const logClick = () =&gt; console.log('button was clicked');
  const logClickWithArg = (message) =&gt; console.log('button was clicked: ', message);
  </code></pre>
  
  <p>You pass them to a component, and in that component you have two buttons:</p>
  
  <pre><code>&lt;button
    onClick={logClick}
  &gt;
    Click
  &lt;/button&gt;
  &lt;button
    onClick={() =&gt; logClickWithArg('hello')}
  &gt;
    Click With Arg
  &lt;/button&gt;
  </code></pre>
  
  <p>When I test the first button, there's no problem:</p>
  
  <pre><code>  expect(wrapper.contains(
      &lt;button
        onClick={logClick}
      &gt;
        Click
      &lt;/button&gt;)).toBe(true);
  </code></pre>
  
  <p>it passes. However, the second:</p>
  
  <pre><code>  expect(wrapper.contains(
      &lt;button
        onClick={() =&gt; logClickWithArg('hello')}
      &gt;
        Click
      &lt;/button&gt;)).toBe(true);
  </code></pre>
  
  <p>fails with the unhelpful output:</p>
  
  <pre><code>  expect(received).toBe(expected)
  
      Expected value to be (using ===):
        true
      Received:
        false
  
        at Object.&lt;anonymous&gt;.it (src/App.test.js:42:3)
        at process._tickCallback (internal/process/next_tick.js:103:7)
  </code></pre>
  
  <p>I've tried to find out more by trying all kinds of comparisons, like:</p>
  
  <pre><code>console.log('first ', wrapper.find('button').first().props().onClick);
  console.log('last ', wrapper.find('button').last().props().onClick);
  expect(wrapper.find('button').first().props().onClick).toEqual(logClick);
  expect(wrapper.find('button').last().props().onClick).toEqual(logClickWithArg);
  </code></pre>
  
  <p>which results in:</p>
  
  <pre><code>  console.log src/App.test.js:29
      first  () =&gt; console.log('button was clicked')
  
    console.log src/App.test.js:30
      last  () =&gt; logClickWithArg('hello')
  
  expect(received).toEqual(expected)
  
      Expected value to equal:
        [Function logClickWithArg]
      Received:
        [Function onClick]
  </code></pre>
  
  <p>I am using Jest as a test-runner, and encountered this in both the create-react-app and react-boilerplate set-up.
  Any idea what I am doing wrong?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'll give my own workaround in an answer below. I'll use my actual code there instead of these examples. However, I am still curious why the test here fails ....</p>