Q:

Mocha Test, Yeoman, Chrome Extension

I created a project with the generator for Chrome extensions. Below is a representation of my folder structure.
my-wonderful-chrome-extension
   app
     scripts
        common.js
   test
     index.html
     spec
        test.js

I want to test the common.js. My understanding of Mocha is that I should have a index.html file like this:
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Mocha Spec Runner</title>
        <link rel="stylesheet" href="bower_components/mocha/mocha.css">
    </head>
    <body>
        <div id="mocha"></div>
        <script src="bower_components/mocha/mocha.js"></script>
        <script>    
            mocha.setup('bdd');
            mocha.reporter('html');
        </script>
        <script src="bower_components/chai/chai.js"></script>
        <script>
            var assert = chai.assert;
            var expect = chai.expect;
            var should = chai.should();
        </script>

        <!-- include source files here... -->
        <script src="../app/scripts/common.js"></script>

        <!-- include spec files here... -->
        <script src="spec/test.js"></script>

        <script>mocha.run()</script>
    </body>
</html>

The test file (test.js) looks like this: 
/* global describe, it */
describe('Find the root recipe node', function () {
    it('Should not find an elem in null dom', function () {
        console.log(dds_hmr.findRecipeRoot);
    });
});

The common.js file looks like this:
var dds_hmr = {};
dds_hmr.findRecipeRoot = function (elem) {
    if (elem && elem.hasAttribute("itemtype")
            && elem.getAttribute("itemtype") === "http://schema.org/Recipe") {
        return [elem];
    } else {
        var result = [];
        if (elem) {
            for (var i = 0; i < elem.childNodes.length; i++) {
                var child = dds_hmr.findRecipeRoot(elem.childNodes[i]);
                result.concat(child);
            }
        }
        return result;
    }
};

This is the error I'm getting:
1) Find the root recipe node Should not find an elem in null dom:
    ReferenceError: Can't find variable: dds_hmr
        at http://localhost:9000/spec/test.js:4
        at http://localhost:9000/bower_components/mocha/mocha.js:4263
        at http://localhost:9000/bower_components/mocha/mocha.js:4635
        at http://localhost:9000/bower_components/mocha/mocha.js:4694
        at next (http://localhost:9000/bower_components/mocha/mocha.js:4561)
        at http://localhost:9000/bower_components/mocha/mocha.js:4570
        at next (http://localhost:9000/bower_components/mocha/mocha.js:4514)
        at http://localhost:9000/bower_components/mocha/mocha.js:4538
        at timeslice (http://localhost:9000/bower_components/mocha/mocha.js:5531)

What do I need to do to get the test to reference the code in the common.js file?

A:

Turns out that the solution lies in the Grunt configuration (makes sense). In the connect key for the grunt server there is a test key. Under the property options there is another property base. Add 'app' to that list. This will include the app directory at test execution time. From there the trick is to change the script include in the index.html from
<!-- include source files here... -->
<script src="../app/scripts/common.js"></script>

to
<!-- include source files here... -->
<script src="scripts/common.js"></script>

Update: Added the Grunt section
// Grunt server and debug server setting
connect: {
  options: {
    port: 9000,
    livereload: 35729,
    // change this to '0.0.0.0' to access the server from outside
    hostname: 'localhost'
  },
  chrome: {
    options: {
      open: false,
      base: [
        '<%= config.app %>'
      ]
    }
  },
  test: {
    options: {
      open: false,
      base: [
        'test',
        'app',
        '<%= config.app %>'
      ]
    }
  }
}

