Coverage report with istanbul and mocha
<p>I'm a newbie on Node.js. I have to set up some tests in my application and I'm getting really mad trying to generate a back-end code coverage report with <code>mocha</code> and <code>istanbul</code> in my <code>loopback</code> application.</p>

<p>Searching through thousand of dab explained articles on Github I found some good <a href="http://www.vapidspace.com/coding/2014/10/29/code-coverage-metrics-with-mocha-and-istanbul/" rel="nofollow">articles</a> and then I figured out that I had to use something like this:</p>

<pre><code>istanbul cover _mocha -- [path/to/test/files] -R spec
</code></pre>

<p>I was happy because it says: "What you are essentially doing is passing the command to run your tests to Istanbul which, in turn, will run those tests on your behalf." However, every time I try to run Istanbul, I get this error:</p>

<pre><code>No coverage information was collected, exit without writing coverage information
C:\...\proj-name\node_modules\.bin\_mocha:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
</code></pre>

<p>My working test file is:</p>

<pre><code>var userService = require('../TestBusinessLogic.js');
var should = require('chai').should();

describe('API Utenti', function() {
  it('should throw Exception on missing UserName', function() {
    (function() {
      userService({ Name: 'Pippo', Surname: 'Baudo' });
    }).should.Throw(Error);
  });
});
</code></pre>

<p>Is this command good to use? If not, could someone please explain me how to make a coverage report using <code>istanbul</code> with <code>mocha</code>?</p>