I have a minimal browser JavaScript project using QUnit which I wrote using the example provided by QUnit docs. Here is the source code:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>QUnit Example</title>
<link rel="stylesheet" href="qunit-2.6.2.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="qunit-2.6.2.js"></script>
<script src="example.js"></script>
<script src="tests.js"></script>
</body>
</html>
example.js
/**
* Returns a sum of two numbers
*
* @param {number} - first number
* @param {number} - second number
*
* @returns {number}
*/
function mysum(arg1, arg2) {
var ret;
ret = arg1 + arg2;
return ret;
}
mysum(1, 2);
tests.js
QUnit.test( "hello test", function( assert ) {
assert.ok( 1 == "1", "Passed!" );
});
QUnit.test( "mysum test", function( assert ) {
assert.ok( mysum(1, 2) == 3, "Passed!" );
});
Tests run fine when I open index.html in the browser. My goal is to add coverage reports before I start extending it. First I wanted to use Blanket.js, because it promises to work with QUnit. I tried to reproduce the steps described in their getting started tutorial but it didn't work (I saw no added coverage related content in the browser) and I couldn't figure out what's wrong (there was no content in the browser's JavaScript console). However, Blanket.js claims to be unmaintained and recommends Istanbul. As I understand from its README, istanbul cover is for node scripts (my project is browser only) and istanbul instrument . -o coverage just generates a directory with JavaScript source code files only and I have no idea what to do with them.
How to get HTML coverage reports like these for my project using Istanbul?