I have installed mocha globally and use it to run some tests:
$> mocha test.js
In the root of test.js file I want to monkey patch mocha:
require('mocha').Runner.prototype.runTests = function() {...}
however require('mocha') fails since mocha is not in node_modules but installed globally.
If I install mocha locally in my project then require('mocha') finds it but it is not the same module as the ambient one used for execution so the patch is not good.
If I run mocha from the local repository rather than the global one then everything works fine:
$> ./node_modules/mocha/bin/mocha test.js
however I want to run mocha from the global repository. any idea?
EDIT: I gave up on the attempt to access the global mocha module and it seems runing mocha locally and requiring it locally is good enough for my use case.