Could not override functions in Sails.js app
enuggetry opened this issue · comments
Eric Y commented
I just couldn't get it to override any of my functions.
var proxyquire = require('proxyquire');
var utilsStub = {};
utilsStub.myGET = function(api) {
console.log('>>>>> stubbed utils.myGET()',api);
}
var Sails = proxyquire('sails',{'./utils': utilsStub}).Sails;
I ended up using mock-require -- had no problems.
Ben Drucker commented
I haven't used Sails. You'll have to share a project with us that I can run npm install && npm test
on and see the error. Your code looks pretty fishy (is sails/utils
a module?) but we won't be able to help without a full example.