title: karma-jasmine - how to test return object
body: <p>I'm trying to add a test that will cover the return statement in the CommonJS file, <code>module1.js</code>, please see the attached image.</p>
  
  <p>Here's what I'm currently trying:</p>
  
  <pre><code>describe("Module 1 ", () =&gt; {
      let mod, testMod = null;
  
      beforeEach(() =&gt; {
          mod = {
              module1: require('../src/app/js/module1/module1')
          };
  
          spyOn(mod, 'module1');
          testMod = mod.module1();
          console.log(testMod);
          console.log(mod.module1);
      });
      it('is executed', () =&gt; {
          expect(mod.module1).toHaveBeenCalled();
      });
  });
  </code></pre>
  
  <p>Module1 file:</p>
  
  <pre><code>/**
   * Represents module1.
   * @module module1
   */
  
  function module1() {
      let x = 13;
  
      return {
          getUserAgent: getUserAgent
      };
  
      /**
       * Return the userAgent of the browser.
       * @func getUserAgent
       */
      function getUserAgent() {
          return window.navigator.userAgent
      }
  }
  
  module.exports = module1;
  </code></pre>
  
  <p>Log output:</p>
  
  <pre><code>LOG: undefined
  LOG: function () { ... }
  </code></pre>
  
  <p>UPDATE: When I log <code>mod.module.toString</code>, the console logs:</p>
  
  <p><code>function () { return fn.apply(this, arguments); }</code></p>
  
  <p>Why isn't my module there?</p>
  
  <p>Am I trying the right approach here? Why doesn't <code>mod.module1();</code> work?</p>
  
  <p><a href="https://i.stack.imgur.com/VOK7p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VOK7p.png" alt="Istanbul coverage Report"></a></p>