title: Why is my typeof check undefined failing my Mocha test?
body: <p>This code does not pass the test</p>
  
  <p><strong>Functions:</strong></p>
  
  <pre><code>function setTheme(theme) {
      chartTheme = theme;
  }
  
  function getTheme() {
      if (typeof chartTheme === undefined) {
          chartTheme = 'dark';
      }
      return chartTheme;
  }
  </code></pre>
  
  <p><strong>Test:</strong></p>
  
  <pre><code>it('If theme is undefined, expect dark', function() {
      ChartFactory.setTheme(undefined);
      expect(ChartFactory.getTheme()).to.equal('dark');
  });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/y6ue8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y6ue8.png" alt="enter image description here"></a></p>
  
  <p>However this does past the test, if I check for <code>"undefined"</code> as a string.</p>
  
  <pre><code>function getTheme() {
      if (typeof chartTheme === 'undefined') {
          chartTheme = 'dark';
      }
      return chartTheme;
  }
  </code></pre>