title: React testing library - TypeError: expect(...).toHaveTextContent is not a function
body: <p>I'm following a simple tutorial to learn react testing library.</p>
  <p>I have a simple component like:</p>
  <pre><code>import React, {useState} from 'react';
  
  const TestElements = () =&gt; {
    const [counter, setCounter] = useState(0)
  
    return(
      &lt;&gt;
        &lt;h1 data-testid=&quot;counter&quot; &gt;{ counter }&lt;/h1&gt;
        &lt;button data-testid=&quot;button-up&quot; onClick={() =&gt; setCounter(counter + 1)}&gt;Up&lt;/button&gt;
        &lt;button data-testid=&quot;button-down&quot; onClick={() =&gt; setCounter(counter - 1)}&gt;Down&lt;/button&gt;
      &lt;/&gt;
    )
  }
  
  export default TestElements
  </code></pre>
  <p>And a test file like:</p>
  <pre><code>import React from 'react';
  import {render, cleanup} from '@testing-library/react'
  import TestElements from './TestElements';
  
  afterEach(cleanup);
  
  test('should equal to 0', () =&gt; {
      const { getByTestId } = render(&lt;TestElements /&gt;)
      expect(getByTestId('counter')).toHaveTextContent(0)
  });
  </code></pre>
  <p>But if I run the test, I'm getting the following error:</p>
  <pre><code>TypeError: expect(...).toHaveTextContent is not a function
  </code></pre>
  <p>I'm using create-react-app and the <code>package.json</code> shows:</p>
  <pre><code>&quot;@testing-library/jest-dom&quot;: &quot;^4.2.4&quot;,
  </code></pre>
  <p>Do I need to add jest as well?</p>