title: Uncaught ReferenceError: require is not defined
body: <p>For a project that I am working on I have been using a hodgepodge of JavaScript libraries.  The main logic of my code is broken down into multiple commonjs modules.  I use google closure  to combine the modules into one output js file which I use within my AngularJS application.</p>
  
  <p>The problem I am having is trying to perform tests with testacular.  There error I receive is <code>Uncaught ReferenceError: require is not defined</code>.  It is happening because, unlike google closure, testacular doesn't understand commonjs modules.  There are a couple work arounds I can do, but I was hoping to make it work without having to restructure my code.  </p>
  
  <ol>
  <li>I can restucture the modules so that I'm no longer using commonjs.  I don't like this because it feels like a step backwards.  I want my code to be modular.</li>
  <li>I can run testacular on the compiled js from google closure.  I don't mind doing it this way, but I have not been able to trigger everything to work on file changes.  Testacular can re-run itself on file changes, but I haven't seen anyway to make google closure re-compile on changes.</li>
  <li>Finally, I can enable commonjs module in testacular.  Ideally this is the way I want to go, but it may not be the easiest.</li>
  </ol>
  
  <p>Has anyone else run into a similar problem?  I'm open for trying different things; I just don't want anything hacky.</p>
  
  <p><strong>javaclassstreamreader.spec.js:</strong></p>
  
  <pre><code>"use strict"
  
  var JavaClassStreamReader = require('../javaclassstreamreader.js').JavaClassStreamReader;
  
  describe('javaclassstreamreader', function() {
  
    it('reader can be constructed', function() {
      var dataView = {
        byteLength : 0
      };
      //FIXME load dataView
  
      var reader = new JavaClassStreamReader(dataView);
      expect(reader.dataView).toBe(dataView);
      expect(reader.offset).toBe(0);
      expect(reader.maxOffset).toBe(0);
    });
  
  });
  </code></pre>
  
  <p><strong>javaclassstreamreader.js:</strong></p>
  
  <pre><code>function JavaClassStreamReader(dataView, initialOffset, maxBytesToRead) {
    this.dataView = dataView;
    this.offset = initialOffset || 0;
    this.maxOffset = this.offset + (maxBytesToRead || this.dataView.byteLength);
  }
  //... code trucated ...
  </code></pre>