You probably know that to do JavaScript testing is good and some hurdles to overcome is how to test our code in a manner to (i) inject mocks for other modules, (ii) to leak private variables or (iii) override variables within the module.
rewire is a tool for helping us on overcoming these hurdles. It provides us an easy way to dependency injection for unit testing and adds a special setter and getter to modules so we can modify their behaviour for better unit testing. What rewire does is to not load the file and eval the contents to emulate the load mechanism.
To get started with dependency injection, we'll create a twitter rest api server and do unit tests using mocks and overriding variables within modules. This e