kibana/docs/developer/contributing/development-tests.asciidoc
Matthew Kime 2fd89943c5
kibana-management team module move (#203883)
## Summary

This PR aims at relocating some of the Kibana modules (plugins and
packages) into a new folder structure, according to the _Sustainable
Kibana Architecture_ initiative.

> [!IMPORTANT]
> * We kindly ask you to:
> * Manually fix the errors in the error section below (if there are
any).
> * Search for the `packages[\/\\]` and `plugins[\/\\]` patterns in the
source code (Babel and Eslint config files), and update them
appropriately.
> * Manually review
`.buildkite/scripts/pipelines/pull_request/pipeline.ts` to ensure that
any CI pipeline customizations continue to be correctly applied after
the changed path names
> * Review all of the updated files, specially the `.ts` and `.js` files
listed in the sections below, as some of them contain relative paths
that have been updated.
> * Think of potential impact of the move, including tooling and
configuration files that can be pointing to the relocated modules. E.g.:
>     * customised eslint rules
>     * docs pointing to source code

> [!NOTE]
> * This PR has been auto-generated.
> * Any manual contributions will be lost if the 'relocate' script is
re-run.
> * Try to obtain the missing reviews / approvals before applying manual
fixes, and/or keep your changes in a .patch / git stash.
> * Please use
[#sustainable_kibana_architecture](https://elastic.slack.com/archives/C07TCKTA22E)
Slack channel for feedback.

#### 17 plugin(s) are going to be relocated:

| Id | Target folder |
| -- | ------------- |
| `@kbn/cloud-data-migration-plugin` |
`x-pack/platform/plugins/private/cloud_integrations/cloud_data_migration`
|
| `@kbn/console-plugin` | `src/platform/plugins/shared/console` |
| `@kbn/cross-cluster-replication-plugin` |
`x-pack/platform/plugins/private/cross_cluster_replication` |
| `@kbn/dev-tools-plugin` | `src/platform/plugins/shared/dev_tools` |
| `@kbn/es-ui-shared-plugin` |
`src/platform/plugins/shared/es_ui_shared` |
| `@kbn/grokdebugger-plugin` |
`x-pack/platform/plugins/private/grokdebugger` |
| `@kbn/index-lifecycle-management-plugin` |
`x-pack/platform/plugins/private/index_lifecycle_management` |
| `@kbn/license-api-guard-plugin` |
`x-pack/platform/plugins/private/license_api_guard` |
| `@kbn/license-management-plugin` |
`x-pack/platform/plugins/shared/license_management` |
| `@kbn/management-plugin` | `src/platform/plugins/shared/management` |
| `@kbn/painless-lab-plugin` |
`x-pack/platform/plugins/private/painless_lab` |
| `@kbn/remote-clusters-plugin` |
`x-pack/platform/plugins/private/remote_clusters` |
| `@kbn/rollup-plugin` | `x-pack/platform/plugins/private/rollup` |
| `@kbn/runtime-fields-plugin` |
`x-pack/platform/plugins/private/runtime_fields` |
| `@kbn/searchprofiler-plugin` |
`x-pack/platform/plugins/shared/searchprofiler` |
| `@kbn/snapshot-restore-plugin` |
`x-pack/platform/plugins/private/snapshot_restore` |
| `@kbn/watcher-plugin` | `x-pack/platform/plugins/private/watcher` |




#### 17 packages(s) are going to be relocated:

| Id | Target folder |
| -- | ------------- |
| `@kbn/deeplinks-devtools` |
`src/platform/packages/shared/deeplinks/devtools` |
| `@kbn/deeplinks-management` |
`src/platform/packages/shared/deeplinks/management` |
| `@kbn/default-nav-devtools` |
`src/platform/packages/private/default-nav/devtools` |
| `@kbn/default-nav-management` |
`src/platform/packages/private/default-nav/management` |
| `@kbn/index-lifecycle-management-common-shared` |
`x-pack/platform/packages/shared/index-lifecycle-management/index_lifecycle_management_common_shared`
|
| `@kbn/index-management-shared-types` |
`x-pack/platform/packages/shared/index-management/index_management_shared_types`
|
| `@kbn/management-cards-navigation` |
`src/platform/packages/shared/kbn-management/cards_navigation` |
| `@kbn/management-settings-application` |
`src/platform/packages/private/kbn-management/settings/application` |
| `@kbn/management-settings-components-field-category` |
`src/platform/packages/private/kbn-management/settings/components/field_category`
|
| `@kbn/management-settings-components-field-input` |
`src/platform/packages/shared/kbn-management/settings/components/field_input`
|
| `@kbn/management-settings-components-field-row` |
`src/platform/packages/shared/kbn-management/settings/components/field_row`
|
| `@kbn/management-settings-components-form` |
`src/platform/packages/private/kbn-management/settings/components/form`
|
| `@kbn/management-settings-field-definition` |
`src/platform/packages/shared/kbn-management/settings/field_definition`
|
| `@kbn/management-settings-types` |
`src/platform/packages/shared/kbn-management/settings/types` |
| `@kbn/management-settings-utilities` |
`src/platform/packages/shared/kbn-management/settings/utilities` |
| `@kbn/rollup` | `x-pack/platform/packages/private/rollup` |
| `@kbn/unsaved-changes-prompt` |
`src/platform/packages/shared/kbn-unsaved-changes-prompt` |


<details >
<summary>Updated references</summary>

```
./.buildkite/scripts/steps/console_definitions_sync.sh
./.eslintrc.js
./.i18nrc.json
./docs/developer/contributing/development-tests.asciidoc
./docs/developer/plugin-list.asciidoc
./package.json
./packages/kbn-generate-console-definitions/README.md
./packages/kbn-repo-packages/package-map.json
./packages/kbn-search-connectors/components/cron_editor/readme.md
./packages/kbn-ts-projects/config-paths.json
./src/dev/precommit_hook/casing_check_config.js
./src/dev/storybook/aliases.ts
./src/platform/packages/private/default-nav/devtools/jest.config.js
./src/platform/packages/private/default-nav/management/jest.config.js
./src/platform/packages/private/kbn-management/settings/components/field_category/jest.config.js
./src/platform/packages/shared/deeplinks/devtools/jest.config.js
./src/platform/packages/shared/deeplinks/management/jest.config.js
./src/platform/packages/shared/kbn-management/cards_navigation/jest.config.js
./src/platform/packages/shared/kbn-unsaved-changes-prompt/jest.config.js
./src/platform/plugins/shared/console/README.md
./src/platform/plugins/shared/console/jest.config.js
./src/platform/plugins/shared/console/server/lib/elasticsearch_proxy_config.test.js
./src/platform/plugins/shared/console/server/lib/spec_definitions/json/README.md
./src/platform/plugins/shared/es_ui_shared/.storybook/manager.ts
./src/platform/plugins/shared/es_ui_shared/jest.config.js
./src/platform/plugins/shared/es_ui_shared/static/forms/README.md
./src/platform/plugins/shared/management/jest.config.js
./src/plugins/advanced_settings/README.md
./src/plugins/management/README.md
./tsconfig.base.json
./x-pack/.i18nrc.json
./x-pack/platform/packages/private/rollup/jest.config.js
./x-pack/platform/packages/shared/index-management/index_management_shared_types/jest.config.js
./x-pack/platform/plugins/private/cloud_integrations/cloud_data_migration/jest.config.js
./x-pack/platform/plugins/private/cross_cluster_replication/jest.config.js
./x-pack/platform/plugins/private/grokdebugger/jest.config.js
./x-pack/platform/plugins/private/index_lifecycle_management/integration_tests/README.md
./x-pack/platform/plugins/private/index_lifecycle_management/jest.config.js
./x-pack/platform/plugins/private/index_lifecycle_management/jest.integration.config.js
./x-pack/platform/plugins/private/license_api_guard/jest.config.js
./x-pack/platform/plugins/private/painless_lab/jest.config.js
./x-pack/platform/plugins/private/remote_clusters/jest.config.js
./x-pack/platform/plugins/private/rollup/jest.config.js
./x-pack/platform/plugins/private/runtime_fields/jest.config.js
./x-pack/platform/plugins/private/snapshot_restore/jest.config.js
./x-pack/platform/plugins/private/watcher/jest.config.js
./x-pack/platform/plugins/shared/license_management/jest.config.js
./x-pack/platform/plugins/shared/searchprofiler/jest.config.js
./x-pack/plugins/index_management/README.md
./x-pack/plugins/triggers_actions_ui/README.md
./x-pack/plugins/triggers_actions_ui/server/data/routes/indices.ts
./x-pack/solutions/security/packages/navigation/src/constants.ts
./x-pack/test/functional/apps/dev_tools/searchprofiler_editor.ts
./yarn.lock
```

</details><details >
<summary>Updated relative paths</summary>

```
src/platform/packages/private/default-nav/devtools/jest.config.js:12
src/platform/packages/private/default-nav/devtools/tsconfig.json:2
src/platform/packages/private/default-nav/management/jest.config.js:12
src/platform/packages/private/default-nav/management/tsconfig.json:2
src/platform/packages/private/kbn-management/settings/application/tsconfig.json:2
src/platform/packages/private/kbn-management/settings/components/field_category/jest.config.js:12
src/platform/packages/private/kbn-management/settings/components/field_category/tsconfig.json:2
src/platform/packages/private/kbn-management/settings/components/form/tsconfig.json:2
src/platform/packages/shared/deeplinks/devtools/jest.config.js:12
src/platform/packages/shared/deeplinks/devtools/tsconfig.json:2
src/platform/packages/shared/deeplinks/management/jest.config.js:12
src/platform/packages/shared/deeplinks/management/tsconfig.json:2
src/platform/packages/shared/kbn-management/cards_navigation/jest.config.js:12
src/platform/packages/shared/kbn-management/cards_navigation/tsconfig.json:2
src/platform/packages/shared/kbn-management/settings/components/field_input/tsconfig.json:2
src/platform/packages/shared/kbn-management/settings/components/field_row/tsconfig.json:2
src/platform/packages/shared/kbn-management/settings/field_definition/tsconfig.json:2
src/platform/packages/shared/kbn-management/settings/types/tsconfig.json:2
src/platform/packages/shared/kbn-management/settings/utilities/tsconfig.json:2
src/platform/packages/shared/kbn-unsaved-changes-prompt/jest.config.js:12
src/platform/packages/shared/kbn-unsaved-changes-prompt/tsconfig.json:2
src/platform/plugins/shared/console/jest.config.js:12
src/platform/plugins/shared/console/tsconfig.json:2
src/platform/plugins/shared/dev_tools/tsconfig.json:2
src/platform/plugins/shared/es_ui_shared/jest.config.js:12
src/platform/plugins/shared/es_ui_shared/tsconfig.json:12
src/platform/plugins/shared/es_ui_shared/tsconfig.json:2
src/platform/plugins/shared/management/jest.config.js:12
src/platform/plugins/shared/management/tsconfig.json:10
src/platform/plugins/shared/management/tsconfig.json:2
x-pack/platform/packages/private/rollup/jest.config.js:10
x-pack/platform/packages/private/rollup/tsconfig.json:2
x-pack/platform/packages/shared/index-lifecycle-management/index_lifecycle_management_common_shared/tsconfig.json:2
x-pack/platform/packages/shared/index-management/index_management_shared_types/jest.config.js:10
x-pack/platform/packages/shared/index-management/index_management_shared_types/tsconfig.json:2
x-pack/platform/plugins/private/cloud_integrations/cloud_data_migration/jest.config.js:10
x-pack/platform/plugins/private/cloud_integrations/cloud_data_migration/tsconfig.json:10
x-pack/platform/plugins/private/cloud_integrations/cloud_data_migration/tsconfig.json:2
x-pack/platform/plugins/private/cross_cluster_replication/jest.config.js:10
x-pack/platform/plugins/private/cross_cluster_replication/tsconfig.json:2
x-pack/platform/plugins/private/grokdebugger/jest.config.js:10
x-pack/platform/plugins/private/grokdebugger/tsconfig.json:10
x-pack/platform/plugins/private/grokdebugger/tsconfig.json:2
x-pack/platform/plugins/private/index_lifecycle_management/jest.config.js:10
x-pack/platform/plugins/private/index_lifecycle_management/jest.integration.config.js:10
x-pack/platform/plugins/private/index_lifecycle_management/tsconfig.json:12
x-pack/platform/plugins/private/index_lifecycle_management/tsconfig.json:2
x-pack/platform/plugins/private/license_api_guard/jest.config.js:10
x-pack/platform/plugins/private/license_api_guard/tsconfig.json:2
x-pack/platform/plugins/private/painless_lab/jest.config.js:10
x-pack/platform/plugins/private/painless_lab/public/styles/_index.scss:1
x-pack/platform/plugins/private/painless_lab/tsconfig.json:2
x-pack/platform/plugins/private/remote_clusters/jest.config.js:10
x-pack/platform/plugins/private/remote_clusters/tsconfig.json:12
x-pack/platform/plugins/private/remote_clusters/tsconfig.json:2
x-pack/platform/plugins/private/rollup/jest.config.js:10
x-pack/platform/plugins/private/rollup/tsconfig.json:2
x-pack/platform/plugins/private/runtime_fields/README.md:155
x-pack/platform/plugins/private/runtime_fields/jest.config.js:10
x-pack/platform/plugins/private/runtime_fields/tsconfig.json:2
x-pack/platform/plugins/private/runtime_fields/tsconfig.json:8
x-pack/platform/plugins/private/snapshot_restore/jest.config.js:10
x-pack/platform/plugins/private/snapshot_restore/tsconfig.json:12
x-pack/platform/plugins/private/snapshot_restore/tsconfig.json:2
x-pack/platform/plugins/private/watcher/jest.config.js:10
x-pack/platform/plugins/private/watcher/tsconfig.json:12
x-pack/platform/plugins/private/watcher/tsconfig.json:2
x-pack/platform/plugins/shared/license_management/jest.config.js:10
x-pack/platform/plugins/shared/license_management/tsconfig.json:2
x-pack/platform/plugins/shared/searchprofiler/jest.config.js:10
x-pack/platform/plugins/shared/searchprofiler/public/application/_app.scss:1
x-pack/platform/plugins/shared/searchprofiler/tsconfig.json:2
```

</details>

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-12-13 12:29:30 -06:00

119 lines
No EOL
4.3 KiB
Text

[[development-tests]]
== Testing
[discrete]
=== Running specific {kib} tests
The following table outlines possible test file locations and how to
invoke them:
[width="100%",cols="7%,59%,34%",options="header",]
|===
|Test runner |Test location |Runner command (working directory is {kib}
root)
|Jest |`**/*.test.{js,mjs,ts,tsx}`
|`yarn test:jest [test path]`
|Jest (integration) |`**/integration_tests/**/*.test.{js,mjs,ts,tsx}`
|`yarn test:jest_integration [test path]`
|Functional
|`test/**/config.js` `x-pack/test/**/config.js`
|`node scripts/functional_tests_server --config [directory]/config.js` `node scripts/functional_test_runner --config [directory]/config.js --grep=regexp`
|===
Test runner arguments: - Where applicable, the optional arguments
`--grep=regexp` will only run tests or test suites
whose descriptions matches the regular expression. - `[test path]` is
the relative path to the test file.
=== Unit Testing
Kibana primarily uses Jest for unit testing. Each plugin or package defines a `jest.config.js` that extends link:{kib-repo}tree/{branch}/packages/kbn-test/jest-preset.js[a preset] provided by the link:{kib-repo}tree/{branch}/packages/kbn-test[`@kbn/test`] package. Unless you intend to run all unit tests within the project, it's most efficient to provide the Jest configuration file for the plugin or package you're testing.
[source,bash]
----
yarn jest --config src/plugins/dashboard/jest.config.js
----
A script is available to provide a better user experience when testing while navigating throughout the repository. To run the tests within your current working directory, use `yarn test:jest`. Like the Jest CLI, you can also supply a path to determine which tests to run.
[source,bash]
----
kibana/src/plugins/dashboard/server$ yarn test:jest #or
kibana/src/plugins/dashboard$ yarn test:jest server #or
kibana$ yarn test:jest src/plugins/dashboard/server
----
Any additional options supplied to `test:jest` will be passed onto the Jest CLI with the resulting Jest command always being outputted.
[source,bash]
----
kibana/src/plugins/dashboard/server$ yarn test:jest --coverage
# is equivalent to
yarn jest --coverage --verbose --config /home/tyler/elastic/kibana/src/plugins/dashboard/jest.config.js server
----
You can generate code coverage report for a single plugin.
[source,bash]
----
yarn jest --coverage --config src/platform/plugins/shared/console/jest.config.js
----
Html report is available in target/kibana-coverage/jest/path/to/plugin
[discrete]
=== Running browser automation tests
Check out <<development-functional-tests>> to learn more about how you can run
and develop functional tests for {kib} core and plugins.
You can also look into the {kib-repo}tree/{branch}/scripts/README.md[Scripts README.md]
to learn more about using the node scripts we provide for building
{kib}, running integration tests, and starting up {kib} and
{es} while you develop.
[discrete]
==== More testing information:
* <<development-functional-tests>>
* <<development-unit-tests>>
* <<development-accessibility-tests>>
* <<development-package-tests>>
include::development-functional-tests.asciidoc[leveloffset=+1]
include::development-unit-tests.asciidoc[leveloffset=+1]
include::development-accessibility-tests.asciidoc[leveloffset=+1]
include::development-package-tests.asciidoc[leveloffset=+1]
[discrete]
=== Cross-browser compatibility
**Testing IE on OS X**
**Note:** IE11 is not supported from 7.9 onwards.
* http://www.vmware.com/products/fusion/fusion-evaluation.html[Download
VMWare Fusion].
* https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/#downloads[Download
IE virtual machines] for VMWare.
* Open VMWare and go to Window > Virtual Machine Library. Unzip the
virtual machine and drag the .vmx file into your Virtual Machine
Library.
* Right-click on the virtual machine you just added to your library and
select "`Snapshots…`", and then click the "`Take`" button in the modal
that opens. You can roll back to this snapshot when the VM expires in 90
days.
* In System Preferences > Sharing, change your computer name to be
something simple, e.g. "`computer`".
* Run {kib} with `yarn start --host=computer.local` (substituting
your computer name).
* Now you can run your VM, open the browser, and navigate to
`http://computer.local:5601` to test {kib}.
* Alternatively you can use browserstack