[mocha] move setup work into module

with https://github.com/elastic/kibana/pull/5553 we added command line flags the told mocha it was supposed to use babel. This changes the strategy here and instead uses mocha's -r option (and it's mocha.opts file to specify it). This means that using mocha directly from the command line still works, and that we have a place where we can do other setup work.
This commit is contained in:
spalger 2016-01-12 16:23:32 -07:00
parent 8e1e85148f
commit c87aec3dae
4 changed files with 12 additions and 2 deletions

View file

@ -55,8 +55,8 @@
"elasticsearch": "grunt esvm:dev:keepalive",
"lint": "grunt eslint:source",
"lintroller": "grunt eslint:fixSource",
"mocha": "mocha --compilers js:babel/register",
"mocha:debug": "mocha --debug-brk --compilers js:babel/register"
"mocha": "mocha",
"mocha:debug": "mocha --debug-brk"
},
"repository": {
"type": "git",

View file

@ -1,3 +1,11 @@
var wrap = require('lodash').wrap;
var Mocha = require('mocha');
Mocha.prototype.run = wrap(Mocha.prototype.run, function (orig) {
require('../../test/mocha_setup');
orig.call(this);
});
module.exports = {
options: {
timeout: 10000,

1
test/mocha.opts Normal file
View file

@ -0,0 +1 @@
-r test/mocha_setup.js

1
test/mocha_setup.js Normal file
View file

@ -0,0 +1 @@
require('babel/register')(require('../src/optimize/babelOptions').node);