Functional Tests for Plugins outside the Kibana repo

Plugins use the FunctionalTestRunner by running it out of the Kibana repo. Ensure that your Kibana Development Environment is setup properly before continuing.

Writing your own configuration

Every project or plugin should have its own FunctionalTestRunner config file. Just like Kibana’s, this config file will define all of the test files to load, providers for Services and PageObjects, as well as configuration options for certain services.

To get started copy and paste this example to test/functional/config.js:

  1. import { resolve } from 'path';
  2. import { resolveKibanaPath } from '@kbn/plugin-helpers';
  3. import { MyServiceProvider } from './services/my_service';
  4. import { MyAppPageProvider } from './services/my_app_page';
  5. // the default export of config files must be a config provider
  6. // that returns an object with the projects config values
  7. export default async function ({ readConfigFile }) {
  8. // read the {kib} config file so that we can utilize some of
  9. // its services and PageObjects
  10. const kibanaConfig = await readConfigFile(resolveKibanaPath('test/functional/config.js'));
  11. return {
  12. // list paths to the files that contain your plugins tests
  13. testFiles: [
  14. resolve(__dirname, './my_test_file.js'),
  15. ],
  16. // define the name and providers for services that should be
  17. // available to your tests. If you don't specify anything here
  18. // only the built-in services will be available
  19. services: {
  20. ...kibanaConfig.get('services'),
  21. myService: MyServiceProvider,
  22. },
  23. // just like services, PageObjects are defined as a map of
  24. // names to Providers. Merge in {kib}'s or pick specific ones
  25. pageObjects: {
  26. management: kibanaConfig.get('pageObjects.management'),
  27. myApp: MyAppPageProvider,
  28. },
  29. // the apps section defines the urls that
  30. // `PageObjects.common.navigateTo(appKey)` will use.
  31. // Merge urls for your plugin with the urls defined in
  32. // {kib}'s config in order to use this helper
  33. apps: {
  34. ...kibanaConfig.get('apps'),
  35. myApp: {
  36. pathname: '/app/my_app',
  37. }
  38. },
  39. // choose where esArchiver should load archives from
  40. esArchiver: {
  41. directory: resolve(__dirname, './es_archives'),
  42. },
  43. // choose where screenshots should be saved
  44. screenshots: {
  45. directory: resolve(__dirname, './tmp/screenshots'),
  46. }
  47. // more settings, like timeouts, mochaOpts, etc are
  48. // defined in the config schema. See {blob}src/functional_test_runner/lib/config/schema.js[src/functional_test_runner/lib/config/schema.js]
  49. };
  50. }

From the root of your repo you should now be able to run the FunctionalTestRunner script from your plugin project.

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

Using esArchiver

We’re working on documentation for this, but for now the best place to look is the original pull request.

Most Popular