Here is a normal node module. With some functions that are not all exported, but they needed to test
var foo1 = function () { console.log("Foo1"); }
var foo2 = function () { console.log("Foo2"); }
var foo3 = function () { console.log("Foo3"); }
module.exports = {
foo1: foo1,
foo2: foo2
}
Anybody knows how to test foo3? Normally I test modules with node-sandboxed-module. But there is only possible to mock given things for the module, but I can not change the scope of methods.
Sample for testing module with node-sandboxed-module:
var SandboxedModule = require('sandboxed-module');
var user = SandboxedModule.require('./user', {
requires: {'mysql': {fake: 'mysql module'}},
globals: {myGlobal: 'variable'},
locals: {myLocal: 'other variable'},
});
Thanks for help!