[mocha] fix test selectors to get everything in packages (#43797) (#43838)

* [mocha] fix test selectors to get everything in packages

* fix paths in tests

* ignore test files that make it into target directories

* [@kbn/test] don't build test files

* move tests from datemath and test-subj pkgs into __tests__ dirs

* [kbn/test-subj] remove test script

* update yarn.lock

# Conflicts:
#	src/dev/mocha/run_mocha_cli.js
This commit is contained in:
Spencer 2019-08-23 07:02:28 -07:00 committed by GitHub
parent f80793b0c0
commit 4023cf1d6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 27 deletions

View file

@ -17,7 +17,7 @@
* under the License.
*/
import dateMath from '../src/index';
import dateMath from '../src';
import moment from 'moment';
import sinon from 'sinon';
import expect from '@kbn/expect';

View file

@ -0,0 +1,22 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { dirname } from 'path';
export const REPO_ROOT = dirname(require.resolve('../../../package.json'));

View file

@ -22,3 +22,4 @@ export { ToolingLog, ToolingLogTextWriter, pickLevelFromFlags } from './tooling_
export { createAbsolutePathSerializer } from './serializers';
export { CA_CERT_PATH, ES_KEY_PATH, ES_CERT_PATH } from './certs';
export { run, createFailError, createFlagError, combineErrors, isFailError } from './run';
export { REPO_ROOT } from './constants';

View file

@ -3,14 +3,7 @@
"version": "0.2.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha test"
},
"keywords": [],
"author": "Spencer Alger <email@spalger.com>",
"license": "Apache-2.0",
"devDependencies": {
"@kbn/expect": "1.0.0",
"mocha": "^2.3.4"
}
"license": "Apache-2.0"
}

View file

@ -5,7 +5,7 @@
"license": "Apache-2.0",
"private": true,
"scripts": {
"build": "babel src --out-dir target --delete-dir-on-start --extensions .ts,.js,.tsx",
"build": "babel src --out-dir target --delete-dir-on-start --extensions .ts,.js,.tsx --ignore *.test.js,**/__tests__/**",
"kbn:bootstrap": "yarn build",
"kbn:watch": "yarn build --watch"
},

View file

@ -21,9 +21,10 @@ import { spawnSync } from 'child_process';
import { resolve } from 'path';
import expect from '@kbn/expect';
import { REPO_ROOT } from '@kbn/dev-utils';
const SCRIPT = resolve(__dirname, '../../../../scripts/functional_test_runner.js');
const BASIC_CONFIG = resolve(__dirname, '../fixtures/simple_project/config.js');
const SCRIPT = resolve(REPO_ROOT, 'scripts/functional_test_runner.js');
const BASIC_CONFIG = require.resolve('../fixtures/simple_project/config.js');
describe('basic config file with a single app and test', function() {
this.timeout(60 * 1000);

View file

@ -22,9 +22,10 @@ import { resolve } from 'path';
import stripAnsi from 'strip-ansi';
import expect from '@kbn/expect';
import { REPO_ROOT } from '@kbn/dev-utils';
const SCRIPT = resolve(__dirname, '../../../../scripts/functional_test_runner.js');
const FAILURE_HOOKS_CONFIG = resolve(__dirname, '../fixtures/failure_hooks/config.js');
const SCRIPT = resolve(REPO_ROOT, 'scripts/functional_test_runner.js');
const FAILURE_HOOKS_CONFIG = require.resolve('../fixtures/failure_hooks/config.js');
describe('failure hooks', function() {
this.timeout(60 * 1000);

View file

@ -17,8 +17,7 @@
* under the License.
*/
import { resolve } from 'path';
import { REPO_ROOT } from '@kbn/dev-utils';
import getopts from 'getopts';
import globby from 'globby';
@ -67,19 +66,17 @@ export function runMochaCli() {
if (!opts._.length) {
globby
.sync(
[
'src/**/__tests__/**/*.js',
'packages/elastic-datemath/test/**/*.js',
'packages/kbn-dev-utils/src/**/__tests__/**/*.js',
'packages/kbn-es-query/src/**/__tests__/**/*.js',
'packages/kbn-eslint-plugin-eslint/**/__tests__/**/*.js',
'tasks/**/__tests__/**/*.js',
],
['src/**/__tests__/**/*.js', 'packages/**/__tests__/**/*.js', 'tasks/**/__tests__/**/*.js'],
{
cwd: resolve(__dirname, '../../..'),
cwd: REPO_ROOT,
onlyFiles: true,
absolute: true,
ignore: ['**/__tests__/fixtures/**', 'src/**/public/**', '**/_*.js'],
ignore: [
'**/__tests__/fixtures/**',
'src/**/public/**',
'**/_*.js',
'packages/**/target/**',
],
}
)
.forEach(file => {

View file

@ -19704,7 +19704,7 @@ mocha@3.5.3:
mkdirp "0.5.1"
supports-color "3.1.2"
mocha@^2.0.1, mocha@^2.3.4:
mocha@^2.0.1:
version "2.5.3"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-2.5.3.tgz#161be5bdeb496771eb9b35745050b622b5aefc58"
integrity sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=