thlorenz / proxyquire

🔮 Proxies nodejs require in order to allow overriding dependencies during testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not override functions in Sails.js app

enuggetry opened this issue · comments

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.

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.