[[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/plugins/console/jest.config.js ---- Html report is available in target/kibana-coverage/jest/path/to/plugin [discrete] === Running browser automation tests Check out <> 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: * <> * <> * <> * <> 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