make server test files an argument

Original commit: elastic/kibana-plugin-helpers@b043b423ef
This commit is contained in:
Joe Fleming 2016-12-15 14:56:47 -07:00
parent 01a8fcee35
commit 867ed91517
2 changed files with 4 additions and 11 deletions

View file

@ -39,9 +39,8 @@ program
.action(run('test/browser'));
program
.command('test:server')
.command('test:server [files...]')
.description('Run the server tests using mocha')
.option('-i, --include <globs>', 'Additional files of glob patterns to include server tests from')
.on('--help', docs('test/server'))
.action(run('test/server'));

View file

@ -2,21 +2,15 @@ var resolve = require('path').resolve;
var delimiter = require('path').delimiter;
var execFileSync = require('child_process').execFileSync;
module.exports = function (plugin, run, command) {
command = command || {};
module.exports = function (plugin, run, files) {
var kibanaBins = resolve(plugin.kibanaRoot, 'node_modules/.bin');
var mochaSetupJs = resolve(plugin.kibanaRoot, 'test/mocha_setup.js');
var cmd = 'mocha';
var args = ['--require', mochaSetupJs, 'server/**/__tests__/**/*.js'];
var testPaths = (files.length) ? files : 'server/**/__tests__/**/*.js';
var args = ['--require', mochaSetupJs].concat(testPaths);
var path = `${kibanaBins}${delimiter}${process.env.PATH}`;
if (command.include) {
var globs = command.include.split(',');
args = args.concat(globs);
}
execFileSync(cmd, args, {
cwd: plugin.root,
stdio: ['ignore', 1, 2],