Kibana 存储库外部插件的功能测试

编辑

Kibana 存储库外部插件的功能测试编辑

插件通过在 Kibana 存储库之外运行 FunctionalTestRunner 来使用它。在继续之前,请确保您的 Kibana 开发环境已正确设置。

编写您自己的配置编辑

每个项目或插件都应该有自己的 FunctionalTestRunner 配置文件。就像 Kibana 的一样,此配置文件将定义要加载的所有测试文件、服务和页面对象的提供程序,以及某些服务的配置选项。

要开始,请将此示例复制并粘贴到 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 Kibana config file so that we can utilize some of
  // its services and PageObjects
  const kibanaConfig = await readConfigFile(resolve(REPO_ROOT, '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 Kibana'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
    // Kibana'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 https://github.com/elastic/kibana/blob/8.14/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts
  };
}

现在,您应该能够从插件项目的根目录运行 FunctionalTestRunner 脚本。

node ../../kibana/scripts/functional_test_runner

使用 esArchiver编辑

我们正在努力编写此方面的文档,但目前,最好的参考位置是原始的 拉取请求