visionmedia/mocha — Issue #277: Set 'require' as a global and Mocha chokes
Author: jprichardson
Created: 2012-02-23 05:07:08+00:00
State: open

I had an odd use case where I wanted to modify the `require` function to perform a poor man's dependency injection.

Something like this:
```javascript
var _oldreq = global.require;
global.require = function(mod) {
//if my module and return mocked functionality
//else return expected modules
}
```

As expected, Mocha complains about `require` global leak. So I added `require` to my allowed globals and then Mocha crashes.