title: Code coverage for Mocha in Windows 7
body: <p>I am trying to do code coverage for <code>mocha</code> using <code>istanbul</code> which I have installed globally:</p>
  
  <p>I do this <a href="https://github.com/nelsonic/learn-mocha" rel="nofollow">as suggested here</a></p>
  
  <pre><code>  E:\Do\learn_mocha&gt;istanbul cover _mocha -- -R spec
  
  C:\Users\Vamsi\AppData\Roaming\npm\_mocha.CMD:1
  (function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0
                                                                ^
  No coverage information was collected, exit without writing coverage information
  
  SyntaxError: Unexpected token ILLEGAL
      at Module._compile (module.js:439:25)
      at Module._extensions..js (module.js:474:10)
      at Object.Module._extensions..js (C:\Users\Vamsi\AppData\Roaming\npm\node_mo
  dules\istanbul\lib\hook.js:102:13)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Function.Module.runMain (module.js:497:10)
      at runFn (C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\comma
  nd\common\run-with-cover.js:114:16)
      at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\command\comm
  on\run-with-cover.js:232:17
      at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
  tcher.js:56:16
      at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
  tcher.js:35:9
  </code></pre>
  
  <p>This command also throws the same error as above:</p>
  
  <pre><code>    E:\Do\learn_mocha&gt;istanbul cover --hook-run-in-context _mocha -- -R spec
  </code></pre>
  
  <p>I was told by a github issue that I had to add a path to mocha from <code>node_modules</code>,so I did this:</p>
  
  <pre><code>    E:\Do\learn_mocha&gt;istanbul cover C:\Users\Vamsi\AppData\Roaming\npm\mocha -- -R
  </code></pre>
  
  <p>spec</p>
  
  <pre><code>C:\Users\Vamsi\AppData\Roaming\npm\mocha:2
  basedir=`dirname "$0"`
          ^
  No coverage information was collected, exit without writing coverage information
  
  SyntaxError: Unexpected token ILLEGAL
      at Module._compile (module.js:439:25)
      at Module._extensions..js (module.js:474:10)
      at Object.Module._extensions..js (C:\Users\Vamsi\AppData\Roaming\npm\node_mo
  dules\istanbul\lib\hook.js:102:13)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Function.Module.runMain (module.js:497:10)
      at runFn (C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\comma
  nd\common\run-with-cover.js:114:16)
      at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\command\comm
  on\run-with-cover.js:232:17
      at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
  tcher.js:56:16
      at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
  tcher.js:35:9
  </code></pre>
  
  <p>I am using Windows 7 as my OS</p>
  
  <p>My test looks like this:</p>
  
  <pre><code>var assert = require("assert"); // core module
  var C = require('../cash.js');  // our module
  
  describe('Cash Register', function(){
    describe('Module C', function(){
  
      it('should have a getChange Method', function(){
        assert.equal(typeof C, 'object');
        assert.equal(typeof C.getChange, 'function');
      })
  
      it('getChange(210,300) should equal [50,20,20]',function(){
          assert.deepEqual(C.getChange(210,300),[50,20,20]);
      })
  
      it('getChange(486,1000) should equal [500,10,2,2]',function(){
          assert.deepEqual(C.getChange(486,1000),[500,10,2,2]);
      })
  
      it('getChange(1487,10000) should equal [5000,2000,1000,500,10,2,1]',function(){
          assert.deepEqual(C.getChange(1487,10000),[5000,2000,1000,500,10,2,1]);
      })
    })
  })  
  </code></pre>