title: How to load your classes in Jest?
body: <p>So this question seems really stupid, but I've been searching and searching, and have not found an answer.</p>
  
  <p>I'm trying out the Jest framework for unit testing my custom javascript project, which is not using React or any other framework.  My project structure currently looks like this:</p>
  
  <ul>
  <li>project
  
  <ul>
  <li>js
  
  <ul>
  <li>main.js &lt;-- all my classes are in here, es6 style, if that matters</li>
  </ul></li>
  <li>--tests--
  
  <ul>
  <li>card.test.js &lt;-- tests are in here</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>Inside main.js there is class Card defined.  I doubt there are any issues with the file, as I've run it perfectly fine in the browser.</p>
  
  <pre><code>"use strict";
  
  class Card 
  {
    ...
  }
  </code></pre>
  
  <p>The one test I've written so far, just to see if it works is:</p>
  
  <pre><code>require('../js/main.js');
  
  test("stuff", () =&gt; {
      let card = new Card(1, 1);
  });
  </code></pre>
  
  <p>When I try to run the test:</p>
  
  <p><code>yarn test</code></p>
  
  <p>But all I'm getting is:</p>
  
  <pre><code>    ReferenceError: Card is not defined
  
        2 |
        3 | test("stuff", () =&gt; {
      &gt; 4 |       let card = new Card(1, 1);
          |                  ^
        5 | });
  
        at Object.&lt;anonymous&gt;.test (__tests__/card.test.js:4:13)
  </code></pre>
  
  <p>It seems like main.js is getting loaded, because if I add a console.log() in it, that gets output when I run the test.  So why is it complaining that Card is not defined?</p>