title: Testing with Jest - TypeError: cannot read property 'forEach' of undefined
body: <p>I created a sample project to write tests with Jest. I followed some tutorials.</p>
  
  <p>I added a simple calculation function in a typescript file as below.</p>
  
  <p><strong>Calc.cs</strong></p>
  
  <pre><code> export class Calc {
      public add(num1: number, num2: number) : number {
        return num1 + num2;
      }
      public subtract(num1: number, num2: number) : number {
        return num1 - num2;
      }
    }
  </code></pre>
  
  <p>Then added a test file as below.</p>
  
  <pre><code>import { should } from 'chai';
  import { Calc } from './Calc';
  should();
  
  
  let calc = new Calc();
  test('adds 1 + 2 to equal 3', () =&gt; {
      expect(calc.add(1, 2)).toBe(3);
    });
  </code></pre>
  
  <p>Then I tried to run the tests as mentioned below. Then I got this error. </p>
  
  <blockquote>
    <p>PS C:TestProject> npm t</p>
    
    <blockquote>
      <p>typescriptseleniumtestproject@1.0.0 test C:TestProject
      jest</p>
    </blockquote>
    
    <p>C:TestProject\node_modules\jest-haste-map\build\crawlers\node.js:49
          names.forEach(file => {
                ^</p>
    
    <p>TypeError: Cannot read property 'forEach' of undefined
        at default.readdir (C:\TestProject\node_modules\jest-haste-map\build\crawlers\node.js:49:13)
        at go$readdir$cb (C:\TestProject\node_modules\jest\node_modules\graceful-fs\graceful-fs.js:149:14)
        at FSReqWrap.oncomplete (fs.js:135:15) npm ERR! Test failed.  See above for more details.</p>
  </blockquote>
  
  <p>Then I browse to that file which shows an error and it is mentioned below.</p>
  
  <p><a href="https://i.stack.imgur.com/88uHd.png" rel="nofollow noreferrer">node_modules\jest-haste-map\build\crawlers\node.js</a></p>