Kibana 仓库外部插件的功能测试
插件通过在 Kibana 仓库外部运行 FunctionalTestRunner
来使用它。在继续之前,请确保您的 Kibana 开发环境已正确设置。
每个项目或插件都应该有自己的 FunctionalTestRunner
配置文件。就像 Kibana 的一样,此配置文件将定义要加载的所有测试文件,Services 和 PageObjects 的提供程序,以及某些服务的配置选项。
要开始,请复制并粘贴此示例到 src/platform/test/functional/config.js
import { resolve } from 'path';
import { REPO_ROOT } from '@kbn/utils';
import { MyServiceProvider } from './services/my_service';
import { MyAppPageProvider } from './services/my_app_page';
// the default export of config files must be a config provider
// that returns an object with the projects config values
export default async function ({ readConfigFile }) {
// read the {kib} config file so that we can utilize some of
// its services and PageObjects
const kibanaConfig = await readConfigFile(resolve(REPO_ROOT, 'src/platform/test/functional/config.base.js'));
return {
// list paths to the files that contain your plugins tests
testFiles: [
resolve(__dirname, './my_test_file.js'),
],
// define the name and providers for services that should be
// available to your tests. If you don't specify anything here
// only the built-in services will be available
services: {
...kibanaConfig.get('services'),
myService: MyServiceProvider,
},
// just like services, PageObjects are defined as a map of
// names to Providers. Merge in {kib}'s or pick specific ones
pageObjects: {
management: kibanaConfig.get('pageObjects.management'),
myApp: MyAppPageProvider,
},
// the apps section defines the urls that
// `PageObjects.common.navigateTo(appKey)` will use.
// Merge urls for your plugin with the urls defined in
// {kib}'s config in order to use this helper
apps: {
...kibanaConfig.get('apps'),
myApp: {
pathname: '/app/my_app',
}
},
// choose where screenshots should be saved
screenshots: {
directory: resolve(__dirname, './tmp/screenshots'),
}
// more settings, like timeouts, mochaOpts, etc are
// defined in the config schema.
// See {kibana-blob}packages/kbn-test/src/functional_test_runner/lib/config/schema.ts
};
}
从您的仓库的根目录,您现在应该能够从您的插件项目运行 FunctionalTestRunner
脚本。
node ../../kibana/scripts/functional_test_runner
我们正在编写此文档,但目前最好的查找地点是原始的 pull request。