Fix plugin-helpers test:server task (#31034) (#31076)

* [plugin-helpers/testServer] use scripts/mocha

* [yarn] sync eslint-plugin-jest with kibana while I'm here
This commit is contained in:
Spencer 2019-02-14 13:49:20 -08:00 committed by GitHub
parent 83d0847130
commit 056122a470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 20 deletions

View file

@ -30,7 +30,7 @@
"eslint": "^5.6.0",
"eslint-plugin-babel": "^5.2.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.22.1",
"eslint-plugin-jest": "^21.26.2",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-mocha": "^5.2.0",
"eslint-plugin-no-unsanitized": "^3.0.2",

View file

@ -15,6 +15,7 @@
"del": "^2.2.2",
"execa": "^1.0.0",
"gulp-rename": "1.2.2",
"globby": "^8.0.1",
"gulp-zip": "^4.1.0",
"inquirer": "^1.2.2",
"minimatch": "^3.0.4",

View file

@ -17,32 +17,30 @@
* under the License.
*/
const resolve = require('path').resolve;
const delimiter = require('path').delimiter;
const execFileSync = require('child_process').execFileSync;
const winCmd = require('../../../lib/win_cmd');
const globby = require('globby');
module.exports = function(plugin, run, options) {
options = options || {};
const kibanaBins = resolve(plugin.kibanaRoot, 'node_modules/.bin');
const mochaSetupJs = resolve(plugin.kibanaRoot, 'test/mocha_setup.js');
let testPaths = plugin.serverTestPatterns;
let testPatterns = plugin.serverTestPatterns;
// allow server test files to be overridden
if (options.files && options.files.length) {
testPaths = options.files;
testPatterns = options.files;
}
const fullCmd = resolve(plugin.kibanaRoot, 'node_modules', '.bin', 'mocha');
const cmd = winCmd(fullCmd);
const args = ['--require', mochaSetupJs].concat(testPaths);
const path = `${kibanaBins}${delimiter}${process.env.PATH}`;
execFileSync(cmd, args, {
cwd: plugin.root,
stdio: ['ignore', 1, 2],
env: Object.assign({}, process.env, {
PATH: path,
}),
});
execFileSync(
process.execPath,
[
'scripts/mocha',
...globby.sync(testPatterns, {
cwd: plugin.root,
absolute: true,
}),
],
{
cwd: plugin.kibanaRoot,
stdio: ['ignore', 1, 2],
}
);
};