title: Shared utils functions for testing with Jest
body: <p>I have some utils functions that I'm using among various Jest tests, for example a function like this, for mocking a fetch response:</p>
  
  <pre class="lang-js prettyprint-override"><code>export const mockFetchJsonResponse = (data) =&gt; {
      ok: () =&gt; true,
      json: () =&gt; data
  };
  </code></pre>
  
  <p>I would like to share those functions in a way that I can import them and reuse among my tests. For example:</p>
  
  <pre class="lang-js prettyprint-override"><code>// Some .spec.jsx file
  // ...
  import {mockFetchJsonResponse} from 'some/path/to/shared/tests/utils.jsx'
  
  // Then I can use mockFetchJsonResponse inside this test
  // ...
  </code></pre>
  
  <p>Where should I place such common utils functions?</p>
  
  <p>My project folder looks like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>components/
      CompOne/
          __tests__
          index.jsx
      CompTwo/
          __tests__
          ...
  utils/
      __tests__
      http.js
      user.js
      ...
  </code></pre>
  
  <p>Should I place them inside the <code>utils</code> folder together with other utils functions that I use for my project? Then should I write unit tests also for these functions?</p>