So I'm hoping that the issue is simple and is just me not using istanbul correctly.
I'm using node.js to run Istanbul via the command line.
Using dojo version 1.8.
The problem is Istanbul doesn't seem to be indexing all of the javascript files that are run.
I have two scenarios that show the problem.
Scenario #1: I use dojo's require method to run a javascript file called "test.js". In this scenario, dojo's declare method works and all of the lines in test.js execute (I know this through console.log).
Scenario #1 Problem: Istanbul does not include test.js or show the coverage for this file.
Scenario #2: I use the normal require to run a javascript file called "test.js". In this scenario, dojo's declare method partially works. The second argument (a function) is never executed.
Scenario #2 Problem: Istanbul includes test.js but the function in the declare is not executed.
Here is the test.js.
global.require([], function(){
console.log("Hello World!");
});
global.define([],function(){
console.log('yey');
});
console.log('boo');
Scenario #1 (istanbul-test.js)
dojoConfig = {
async: 1, // We want to make sure we are using the "modern" loader
hasCache: {
"host-node": 1, // Ensure we "force" the loader into Node.js mode
"dom": 0 // Ensure that none of the code assumes we have a DOM
},
packages: [{name: "dojo",location: "dojo"}]
};
require('./dojo/dojo.js');
//global.require is dojo's require
global.require(dojoConfig, ["./test.js"], function(){
console.log('It is finished!');
});
Scenario #2 (istanbul-test2.js)
dojoConfig = {
async: 1, // We want to make sure we are using the "modern" loader
hasCache: {
"host-node": 1, // Ensure we "force" the loader into Node.js mode
"dom": 0 // Ensure that none of the code assumes we have a DOM
},
packages: [{name: "dojo",location: "dojo"}]
};
var dojo = require('./dojo/dojo.js');
require( "./test.js");