Load a module with it's require's mocked out
Works in both node and browserify
varrealB=require("./fixtures/b")varb=mock("./fixtures/b",{fs: {readFileSync: function(uri){if(uri==="clowns.txt"){return"some clowns"}}},"./fixtures/c": null,"./fixtures/a": function(){return42}},require)// use b. It's reference to fs and fixtures/a have been replaced with// your passed objectsLimitations:
- You have to require the thing your mocking out or browserify won't load it and all it's dependencies into the bundle.
- When you set a dependency to null your saying don't overload that dependency with this value, but do nuke it from the cache. This is useful when you want to mock out something ./fixtures/c depends on but not touch the implementation of ./fixtures/c
npm install mock
- Raynos

