kibana/x-pack/test/examples/config.ts
Jiawei Wu 09872f071c
[RAM] Refactor: move shareable component sandbox to its own plugin (#134611)
* Move shareable component sandbox to its own plugin

* Add newline and fix test

* disable lint for no-default-export on example tests

* Fix lint

* Address feedback

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-07-19 09:30:11 -07:00

61 lines
2.1 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { FtrConfigProviderContext } from '@kbn/test';
import { resolve } from 'path';
import fs from 'fs';
import { REPO_ROOT as KIBANA_ROOT } from '@kbn/utils';
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const xpackFunctionalConfig = await readConfigFile(
require.resolve('../functional/config.base.js')
);
// Find all folders in /examples and /x-pack/examples since we treat all them as plugin folder
const examplesFiles = fs.readdirSync(resolve(KIBANA_ROOT, 'examples'));
const examples = examplesFiles.filter((file) =>
fs.statSync(resolve(KIBANA_ROOT, 'examples', file)).isDirectory()
);
const xpackExamplesFiles = fs.readdirSync(resolve(KIBANA_ROOT, 'x-pack/examples'));
const xpackExamples = xpackExamplesFiles.filter((file) =>
fs.statSync(resolve(KIBANA_ROOT, 'x-pack/examples', file)).isDirectory()
);
return {
// default to the xpack functional config
...xpackFunctionalConfig.getAll(),
junit: {
reportName: 'X-Pack Example plugin functional tests',
},
testFiles: [
require.resolve('./search_examples'),
require.resolve('./embedded_lens'),
require.resolve('./reporting_examples'),
require.resolve('./screenshotting'),
require.resolve('./triggers_actions_ui_examples'),
],
kbnTestServer: {
...xpackFunctionalConfig.get('kbnTestServer'),
serverArgs: [
...xpackFunctionalConfig.get('kbnTestServer.serverArgs'),
// Required to load new platform plugins via `--plugin-path` flag.
'--env.name=development',
...examples.map(
(exampleDir) => `--plugin-path=${resolve(KIBANA_ROOT, 'examples', exampleDir)}`
),
...xpackExamples.map(
(exampleDir) => `--plugin-path=${resolve(KIBANA_ROOT, 'x-pack/examples', exampleDir)}`
),
],
},
};
}