How to mock inline requirejs dependencies with squire for unit testing?
问题 I'm using requirejs with inline requires, for instance: define(['someDep'], function(someDep) { return { someFn: function() { require(['anotherDep'], function(anotherDep) { anotherDep.anotherFn(); }); } } }); In my particular case, I cannot include anotherDep in the define. When testing with mocha, I have a test case like this: define(['squire'], function(Squire) { var squire = new Squire(); describe('testcase', function() { it('should mock anotherDep', function(done) { var spy = sinon.spy();