I'm trying to build some unit tests for an old JS file/module that is out of my control.
The JS module is built using the following pattern...
var myModule = {
myMethod:function() {
}
};
I am then trying to build a DOH test harness to test this. I tried the following...
require([
"doh/runner",
"../../myModules/myModule.js"
], function(doh) {
console.log(doh);
console.log(myModule);
});
The file seems to be getting picked up fine but I can't reference anything in it. "console.log(myModule);" just returns undefined.
Anyone know how I can correctly include an external non dojo module JS file in a DOH test harness?
Thanks
myModuleget returned anywhere in the old JS module? If so, you need to add it to your callback, like @DesertIvy mentioned. If it's not, and it's just assigning values to some global variables, you might need to make sure they're actually global by hanging them off the global object, e.g.windowand accessing it likewindow.myModule. - Thomas Uptonwindow.myModule = myModuleat the bottom of your module file? - Thomas Uptonrequiredependency list. Don't include the file extension. - Thomas Upton