I\'m using mocha for javascript unit-testing now.
I have several test files, each file has a before and beforeEach, but they are exactly the s
I've had similar issue when I needed to "mock" global variables used by one of dependencies.
I used .mocharc.js for that, since code in that JS file is being executed once when "mocha" environment is being setup.
Example .mocharc.js:
global.usedVariable = "someDefinedValue";
/** other code to be executed when mocha env setup **/
module.exports = {};
This worked for me, nevertheless this looks quite "dirty" way to do that. Please, comment if you know a better place for that code :)