// lib/fileA.js
var fileB = require('./fileB')
module.exports = function(stuff){
// do stuff
var b = new fileB();
b.save(stuff)
// do more stuff
}
// lib/fileB.js
function fileB() {}
module.exports = fileB;
fileB.prototype.save = function(data) {
// do stuff
return data;
}
// test/fileA.js
var ProxyQuire = require('proxyquireify')(require);
describe('Stuff', function() {
it('should do stuff', function() {
fileA = ProxyQuire('../lib/fileA', {
'./fileB' : {
save : function() {return true}
}
});
// expect some stuff
});
});
How would I mock fileB, I tried the above and got the following error:
TypeError: Property description must be an object.
at forEachOwnPropertyName (/var/folders/96/pzs4pwm178sg9rwc9697xftc0000gn/T/b94babfa2ade028b18862aa5c410c99a.browserify:10086:0 <- ../node_modules/proxyquireify/node_modules/fill-keys/node_modules/merge-descriptors/index.js:54:0)
How would I mock fileB, I tried the above and got the following error: TypeError: Property description must be an object. at forEachOwnPropertyName (/var/folders/96/pzs4pwm178sg9rwc9697xftc0000gn/T/b94babfa2ade028b18862aa5c410c99a.browserify:10086:0 <- ../node_modules/proxyquireify/node_modules/fill-keys/node_modules/merge-descriptors/index.js:54:0)