mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[FTR] Refactor mocha under @kbn/test (#42862)
* Run prettier on the files that will be refactored under @kbn/test, in a follow-up pr. * Fixup all paths to mocha, under kbn-test, with needed exports/imports. * Fixed borked path (bad refactor). * Fixup one more borked path. * Fixup tsconfig for xml.ts * Drop setup_node_env as it's already in KIBANA/scripts/mocha.js. Also, fixup cwd for globby as we are exec-ing from a different directory.
This commit is contained in:
parent
90892da940
commit
5d8ad40c5c
15 changed files with 19 additions and 13 deletions
|
@ -23,12 +23,11 @@ import Mocha from 'mocha';
|
|||
import { ToolingLogTextWriter } from '@kbn/dev-utils';
|
||||
import moment from 'moment';
|
||||
|
||||
import { setupJUnitReportGeneration } from '../../../../../../../src/dev';
|
||||
import { recordLog, snapshotLogsForRunnable, setupJUnitReportGeneration } from '../../../../mocha';
|
||||
import * as colors from './colors';
|
||||
import * as symbols from './symbols';
|
||||
import { ms } from './ms';
|
||||
import { writeEpilogue } from './write_epilogue';
|
||||
import { recordLog, snapshotLogsForRunnable } from '../../../../../../../src/dev/mocha/log_cache';
|
||||
|
||||
export function MochaReporterProvider({ getService }) {
|
||||
const log = getService('log');
|
||||
|
|
|
@ -32,3 +32,10 @@ export { setupUsers, DEFAULT_SUPERUSER_PASS } from './functional_tests/lib/auth'
|
|||
export { readConfigFile } from './functional_test_runner/lib/config/read_config_file';
|
||||
|
||||
export { runFtrCli } from './functional_test_runner/cli';
|
||||
|
||||
export {
|
||||
createAutoJUnitReporter,
|
||||
runMochaCli,
|
||||
setupJUnitReportGeneration,
|
||||
escapeCdata,
|
||||
} from './mocha';
|
||||
|
|
|
@ -20,3 +20,5 @@
|
|||
export { createAutoJUnitReporter } from './auto_junit_reporter';
|
||||
export { setupJUnitReportGeneration } from './junit_report_generation';
|
||||
export { runMochaCli } from './run_mocha_cli';
|
||||
export { recordLog, snapshotLogsForRunnable } from './log_cache';
|
||||
export { escapeCdata } from './xml';
|
|
@ -25,14 +25,14 @@ import mkdirp from 'mkdirp';
|
|||
import xmlBuilder from 'xmlbuilder';
|
||||
|
||||
import { getSnapshotOfRunnableLogs } from './log_cache';
|
||||
import { escapeCdata } from '../xml';
|
||||
import { escapeCdata } from '../';
|
||||
|
||||
const dateNow = Date.now.bind(Date);
|
||||
|
||||
export function setupJUnitReportGeneration(runner, options = {}) {
|
||||
const {
|
||||
reportName = 'Unnamed Mocha Tests',
|
||||
rootDirectory = dirname(require.resolve('../../../package.json')),
|
||||
rootDirectory = dirname(require.resolve('../../../../package.json')),
|
||||
} = options;
|
||||
|
||||
const stats = {};
|
|
@ -41,9 +41,6 @@ export function runMochaCli() {
|
|||
// prevent globals injected from canvas plugins from triggering leak check
|
||||
process.argv.push('--globals', '__core-js_shared__,core,_, ');
|
||||
|
||||
// ensure that mocha requires the setup_node_env script
|
||||
process.argv.push('--require', require.resolve('../../setup_node_env'));
|
||||
|
||||
// set default test timeout
|
||||
if (opts.timeout == null && !opts['no-timeouts']) {
|
||||
if (runInBand) {
|
||||
|
@ -76,7 +73,7 @@ export function runMochaCli() {
|
|||
'tasks/**/__tests__/**/*.js',
|
||||
],
|
||||
{
|
||||
cwd: resolve(__dirname, '../../..'),
|
||||
cwd: resolve(__dirname, '../../../..'),
|
||||
onlyFiles: true,
|
||||
absolute: true,
|
||||
ignore: ['**/__tests__/fixtures/**', 'src/**/public/**', '**/_*.js'],
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
// when the reporter is loaded by mocha in child process it might be before setup_node_env
|
||||
require('../../setup_node_env');
|
||||
require('../../../../src/setup_node_env');
|
||||
|
||||
module.exports = require('./auto_junit_reporter').createAutoJUnitReporter({
|
||||
reportName: 'Server Mocha Tests',
|
|
@ -2,6 +2,7 @@
|
|||
"extends": "../../tsconfig.json",
|
||||
"include": [
|
||||
"types/**/*",
|
||||
"src/functional_test_runner/**/*"
|
||||
"src/functional_test_runner/**/*",
|
||||
"src/mocha/xml.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -18,4 +18,4 @@
|
|||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('../src/dev/mocha').runMochaCli();
|
||||
require('@kbn/test').runMochaCli();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
export {
|
||||
createAutoJUnitReporter,
|
||||
setupJUnitReportGeneration,
|
||||
} from './mocha';
|
||||
} from '@kbn/test';
|
||||
|
||||
export {
|
||||
generateNoticeFromSource,
|
||||
|
|
|
@ -23,7 +23,7 @@ import { writeFileSync } from 'fs';
|
|||
import mkdirp from 'mkdirp';
|
||||
import xmlBuilder from 'xmlbuilder';
|
||||
|
||||
import { escapeCdata } from '../xml';
|
||||
import { escapeCdata } from '@kbn/test';
|
||||
|
||||
const ROOT_DIR = dirname(require.resolve('../../../package.json'));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue