thlorenz / proxyquireify

browserify >= v2 version of proxyquire. Mocks out browserify's require to allow stubbing out dependencies while testing.
MIT License
152 stars 24 forks source link

TypeError: Property description must be an object. #36

Closed jacinto123 closed 9 years ago

jacinto123 commented 9 years ago
// 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)

bendrucker commented 9 years ago

99.9% sure this is #35. If not please share other details and I'll reopen.