If only an initialization code is required, mocha -r ./init may be enough mocha -r ./init . even put it in test/mocha.opts
--require ./test/init --ui tdd
But if you need tearing action, a dilemma arises, for example:
var app = require('../app.js'); app.listen(process.env.WEB_PORT); after(function(done) { var db = mongoskin.db(process.env.DB_URL, {safe:true}); db.dropDatabase(function(err) { expect(err).to.not.be.ok(); db.close(done); }); });
You will receive an error message:
ReferenceError: after is not defined
I think mocha was not initialized during the '--require' processing.
source share