This is a trivial example that illustrates the crux of my problem:
var innerLib = require(\'./path/to/innerLib\');
function underTest() {
return innerLi
I use mock-require. Make sure you define your mocks before you require
the module to be tested.
You can use mockery library:
describe 'UnderTest', ->
before ->
mockery.enable( warnOnUnregistered: false )
mockery.registerMock('./path/to/innerLib', { doComplexStuff: -> 'Complex result' })
@underTest = require('./path/to/underTest')
it 'should compute complex value', ->
expect(@underTest()).to.eq 'Complex result'