title: How to use CodeceptJS to unit-test a JS function
body: <p>I've set up CodeceptJS for a project and use it to test various end-to-end scenarios.</p>
  <p>Now I want to extend the tests-suite to <strong>also run unit-tests</strong> to verify functionality of custom JS functions.</p>
  <p>For example: I have a global object <code>App</code> that has a <code>version</code> attribute. As a first test, I want to confirm that <code>App.version</code> is present and has a value.</p>
  <p>My first attempt is a test.js file with the following code:</p>
  <pre><code>Feature('Unit Tests');
  
  Scenario('Test App presence', ({ I }) =&gt; {
      I.amOnPage('/');
  
      I.executeScript(function() {return App.version})
          .then(function(value) { I.say(value) } );
  });
  </code></pre>
  <p><strong>Problems with this code</strong></p>
  <ol>
  <li>The major issue: How can I assert that the <code>App.version</code> is present?<br />
  My script can display the value but does not fail if it's missing</li>
  <li>My code is very complex for such a simple test.<br />
  I'm sure there's a cleaner/faster way to perform that test, right?</li>
  </ol>