test:jest improvements to better support our monorepo (#84848) (#85880)

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
# Conflicts:
#	docs/developer/contributing/development-functional-tests.asciidoc
#	test/scripts/jenkins_unit.sh
#	test/scripts/jenkins_xpack.sh
#	x-pack/README.md

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tyler Smalley 2020-12-15 09:11:51 -08:00 committed by GitHub
parent 4f840bc5e8
commit 82225db0a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 283 additions and 194 deletions

View file

@ -6,7 +6,5 @@ source "$(dirname "${0}")/../util.sh"
export JOB=kibana-default-jest
cd "$XPACK_DIR"
checks-reporter-with-killswitch "Jest Unit Tests" \
node scripts/jest --bail --debug
node scripts/jest x-pack --ci --verbose --maxWorkers=5

View file

@ -7,4 +7,4 @@ source "$(dirname "${0}")/../util.sh"
export JOB=kibana-oss-jest
checks-reporter-with-killswitch "OSS Jest Unit Tests" \
node scripts/jest --ci --verbose
node scripts/jest --config jest.config.oss.js --ci --verbose --maxWorkers=5

View file

@ -7,4 +7,4 @@ source "$(dirname "${0}")/../util.sh"
export JOB=kibana-oss-jest-integration
checks-reporter-with-killswitch "OSS Jest Integration Tests" \
node scripts/jest_integration --verbose
node scripts/jest_integration --ci --verbose

View file

@ -6,7 +6,7 @@ We use functional tests to make sure the {kib} UI works as expected. It replaces
[discrete]
=== Running functional tests
The `FunctionalTestRunner` is very bare bones and gets most of its functionality from its config file, located at link:{kib-repo}tree/{branch}/test/functional/config.js[test/functional/config.js]. If youre writing a plugin outside the {kib} repo, you will have your own config file.
The `FunctionalTestRunner` is very bare bones and gets most of its functionality from its config file, located at {blob}test/functional/config.js[test/functional/config.js] or {blob}x-pack/test/functional/config.js[x-pack/test/functional/config.js]. If youre writing a plugin outside the {kib} repo, you will have your own config file.
See <<external-plugin-functional-tests>> for more info.
There are three ways to run the tests depending on your goals:

View file

@ -1,8 +1,6 @@
[[development-tests]]
== Testing
To ensure that your changes will not break other functionality, please run the test suite and build (<<building-kibana>>) before submitting your Pull Request.
[discrete]
=== Running specific {kib} tests
@ -13,37 +11,81 @@ invoke them:
|===
|Test runner |Test location |Runner command (working directory is {kib}
root)
|Jest |`src/**/*.test.js` `src/**/*.test.ts`
|`yarn test:jest -t regexp [test path]`
|Jest |`**/*.test.{js,mjs,ts,tsx}`
|`yarn test:jest [test path]`
|Jest (integration) |`**/integration_tests/**/*.test.js`
|`yarn test:jest_integration -t regexp [test path]`
|Jest (integration) |`**/integration_tests/**/*.test.{js,mjs,ts,tsx}`
|`yarn test:jest_integration [test path]`
|Mocha
|`src/**/__tests__/**/*.js` `!src/**/public/__tests__/*.js` `packages/kbn-dev-utils/src/**/__tests__/**/*.js` `tasks/**/__tests__/**/*.js`
|`**/__tests__/**/*.js`
|`node scripts/mocha --grep=regexp [test path]`
|Functional
|`test/*integration/**/config.js` `test/*functional/**/config.js` `test/accessibility/config.js`
|`yarn test:ftr:server --config test/[directory]/config.js``yarn test:ftr:runner --config test/[directory]/config.js --grep=regexp`
|`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`
|===
For X-Pack tests located in `x-pack/` see
link:{kib-repo}tree/{branch}/x-pack/README.md#testing[X-Pack Testing]
Test runner arguments: - Where applicable, the optional arguments
`-t=regexp` or `--grep=regexp` will only run tests or test suites
`--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.
Examples: - Run the entire elasticsearch_service test suite:
`yarn test:jest src/core/server/elasticsearch/elasticsearch_service.test.ts`
- Run the jest test case whose description matches
`stops both admin and data clients`:
`yarn test:jest -t 'stops both admin and data clients' src/core/server/elasticsearch/elasticsearch_service.test.ts`
- Run the api integration test case whose description matches the given
string: ``` yarn test:ftr:server config test/api_integration/config.js
yarn test:ftr:runner config test/api_integration/config
=== 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 equivelant to
yarn jest --coverage --verbose --config /home/tyler/elastic/kibana/src/plugins/dashboard/jest.config.js server
----
NOTE: There are still a handful of legacy tests that use the Mocha test runner. For those tests, use `node scripts/mocha --grep=regexp [test path]`. Tests using Mocha are located within `__tests__` directories.
[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>>
include::development-functional-tests.asciidoc[leveloffset=+1]
include::development-unit-tests.asciidoc[leveloffset=+1]
include::development-accessibility-tests.asciidoc[leveloffset=+1]
[discrete]
=== Cross-browser compatibility
@ -69,28 +111,4 @@ something simple, e.g. "`computer`".
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
[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>>
include::development-functional-tests.asciidoc[leveloffset=+1]
include::development-unit-tests.asciidoc[leveloffset=+1]
include::development-accessibility-tests.asciidoc[leveloffset=+1]
* Alternatively you can use browserstack

View file

@ -43,14 +43,12 @@
"preinstall": "node ./preinstall_check",
"kbn": "node scripts/kbn",
"es": "node scripts/es",
"test": "grunt test",
"test:jest": "node scripts/jest",
"test:jest_integration": "node scripts/jest_integration",
"test:mocha": "node scripts/mocha",
"test:ftr": "node scripts/functional_tests",
"test:ftr:server": "node scripts/functional_tests_server",
"test:ftr:runner": "node scripts/functional_test_runner",
"test:coverage": "grunt test:coverage",
"checkLicenses": "node scripts/check_licenses --dev",
"build": "node scripts/build --all-platforms",
"start": "node scripts/kibana --dev",

View file

@ -62,3 +62,5 @@ export * from './functional_test_runner';
export { getUrl } from './jest/utils/get_url';
export { runCheckJestConfigsCli } from './jest/run_check_jest_configs_cli';
export { runJest } from './jest/run';

View file

@ -0,0 +1,38 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { commonBasePath } from './run';
describe('commonBasePath', () => {
it('returns a common path', () => {
expect(commonBasePath(['foo/bar/baz', 'foo/bar/quux', 'foo/bar'])).toBe('foo/bar');
});
it('handles an empty array', () => {
expect(commonBasePath([])).toBe('');
});
it('handles no common path', () => {
expect(commonBasePath(['foo', 'bar'])).toBe('');
});
it('matches full paths', () => {
expect(commonBasePath(['foo/bar', 'foo/bar_baz'])).toBe('foo');
});
});

View file

@ -0,0 +1,110 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Run Jest tests
//
// Provides Jest with `--config` to the first jest.config.js file found in the current
// directory, or while going up in the directory chain. If the current working directory
// is nested under the config path, a pattern will be provided to Jest to only run the
// tests within that directory.
//
// Any additional options passed will be forwarded to Jest.
//
// See all cli options in https://facebook.github.io/jest/docs/cli.html
import { resolve, relative, sep as osSep } from 'path';
import { existsSync } from 'fs';
import { run } from 'jest';
import { buildArgv } from 'jest-cli/build/cli';
import { ToolingLog } from '@kbn/dev-utils';
// yarn test:jest src/core/server/saved_objects
// yarn test:jest src/core/public/core_system.test.ts
// :kibana/src/core/server/saved_objects yarn test:jest
export function runJest(configName = 'jest.config.js') {
const argv = buildArgv(process.argv);
const log = new ToolingLog({
level: argv.verbose ? 'verbose' : 'info',
writeTo: process.stdout,
});
if (!argv.config) {
const cwd = process.env.INIT_CWD || process.cwd();
const testFiles = argv._.splice(2).map((p) => resolve(cwd, p));
const commonTestFiles = commonBasePath(testFiles);
const testFilesProvided = testFiles.length > 0;
log.verbose('cwd:', cwd);
log.verbose('testFiles:', testFiles.join(', '));
log.verbose('commonTestFiles:', commonTestFiles);
let configPath;
// sets the working directory to the cwd or the common
// base directory of the provided test files
let wd = testFilesProvided ? commonTestFiles : cwd;
configPath = resolve(wd, configName);
while (!existsSync(configPath)) {
wd = resolve(wd, '..');
configPath = resolve(wd, configName);
}
log.verbose(`no config provided, found ${configPath}`);
process.argv.push('--config', configPath);
if (!testFilesProvided) {
log.verbose(`no test files provided, setting to current directory`);
process.argv.push(relative(wd, cwd));
}
log.info('yarn jest', process.argv.slice(2).join(' '));
}
if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'test';
}
run();
}
/**
* Finds the common basePath by sorting the array
* and comparing the first and last element
*/
export function commonBasePath(paths: string[] = [], sep = osSep) {
if (paths.length === 0) return '';
paths = paths.concat().sort();
const first = paths[0].split(sep);
const last = paths[paths.length - 1].split(sep);
const length = first.length;
let i = 0;
while (i < length && first[i] === last[i]) {
i++;
}
return first.slice(0, i).join(sep);
}

View file

@ -17,27 +17,4 @@
* under the License.
*/
// # Run Jest tests
//
// All args will be forwarded directly to Jest, e.g. to watch tests run:
//
// node scripts/jest --watch
//
// or to build code coverage:
//
// node scripts/jest --coverage
//
// See all cli options in https://facebook.github.io/jest/docs/cli.html
if (process.argv.indexOf('--config') === -1) {
// append correct jest.config if none is provided
var configPath = require('path').resolve(__dirname, '../jest.config.oss.js');
process.argv.push('--config', configPath);
console.log('Running Jest with --config', configPath);
}
if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'test';
}
require('jest').run();
require('@kbn/test').runJest();

View file

@ -17,29 +17,6 @@
* under the License.
*/
// # Run Jest integration tests
//
// All args will be forwarded directly to Jest, e.g. to watch tests run:
//
// node scripts/jest_integration --watch
//
// or to build code coverage:
//
// node scripts/jest_integration --coverage
//
// See all cli options in https://facebook.github.io/jest/docs/cli.html
process.argv.push('--runInBand');
if (process.argv.indexOf('--config') === -1) {
// append correct jest.config if none is provided
var configPath = require('path').resolve(__dirname, '../jest.config.integration.js');
process.argv.push('--config', configPath);
console.log('Running Jest with --config', configPath);
}
if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'test';
}
require('jest').run();
require('@kbn/test').runJest('jest.config.integration.js');

View file

@ -206,9 +206,13 @@ There are three core entry points.
## Testing
Run jest tests:
Run Jest tests:
`node scripts/jest --testPathPattern=migrations --watch`
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
```
yarn test:jest src/core/server/saved_objects/migrations --watch
```
Run integration tests:

View file

@ -40,5 +40,5 @@ Run unit tests
[source,sh]
--
node scripts/jest embeddable
yarn test:jest src/plugins/embeddable
--

View file

@ -25,4 +25,4 @@ source test/scripts/jenkins_test_setup.sh
./test/scripts/checks/plugins_with_circular_deps.sh
./test/scripts/checks/verify_notice.sh
./test/scripts/checks/test_projects.sh
./test/scripts/checks/test_hardening.sh
./test/scripts/checks/test_hardening.sh

View file

@ -3,13 +3,4 @@
source test/scripts/jenkins_test_setup.sh
echo " -> Running jest tests"
cd "$XPACK_DIR"
checks-reporter-with-killswitch "X-Pack Jest" node --max-old-space-size=6144 scripts/jest --ci --verbose
echo ""
echo ""
# echo " -> Running jest integration tests"
# cd "$XPACK_DIR"
# node scripts/jest_integration --ci --verbose
# echo ""
# echo ""
./test/scripts/test/xpack_jest_unit.sh

View file

@ -3,4 +3,4 @@
source src/dev/ci_setup/setup_env.sh
checks-reporter-with-killswitch "Jest Integration Tests" \
node scripts/jest_integration
node scripts/jest_integration --ci --verbose

View file

@ -3,4 +3,4 @@
source src/dev/ci_setup/setup_env.sh
checks-reporter-with-killswitch "Jest Unit Tests" \
node scripts/jest
node scripts/jest --config jest.config.oss.js --ci --verbose --maxWorkers=5

View file

@ -2,5 +2,5 @@
source src/dev/ci_setup/setup_env.sh
cd x-pack
checks-reporter-with-killswitch "X-Pack Jest" node --max-old-space-size=6144 scripts/jest --ci --verbose --maxWorkers=10
checks-reporter-with-killswitch "X-Pack Jest" \
node scripts/jest x-pack --ci --verbose --maxWorkers=5

View file

@ -15,41 +15,8 @@ Example: `yarn es snapshot --license trial --password changeme`
By default, this will also set the password for native realm accounts to the password provided (`changeme` by default). This includes that of the `kibana_system` user which `elasticsearch.username` defaults to in development. If you wish to specify a password for a given native realm account, you can do that like so: `--password.kibana_system=notsecure`
# Testing
## Running specific tests
| Test runner | Test location | Runner command (working directory is kibana/x-pack) |
| ------------ | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| Jest | `x-pack/**/*.test.js`<br>`x-pack/**/*.test.ts` | `cd x-pack && node scripts/jest -t regexp [test path]` |
| Functional | `x-pack/test/*integration/**/config.js`<br>`x-pack/test/*functional/config.js` | `node scripts/functional_tests_server --config x-pack/test/[directory]/config.js`<br>`node scripts/functional_test_runner --config x-pack/test/[directory]/config.js --grep=regexp` |
Examples:
- Run the jest test case whose description matches 'filtering should skip values of null':
`cd x-pack && yarn test:jest -t 'filtering should skip values of null' plugins/ml/public/application/explorer/explorer_charts/explorer_charts_container_service.test.js`
- Run the x-pack api integration test case whose description matches the given string:
`node scripts/functional_tests_server --config x-pack/test/api_integration/config.ts`
`node scripts/functional_test_runner --config x-pack/test/api_integration/config.ts --grep='apis Monitoring Beats list with restarted beat instance should load multiple clusters'`
In addition to to providing a regular expression argument, specific tests can also be run by appeding `.only` to an `it` or `describe` function block. E.g. `describe(` to `describe.only(`.
## Running all tests
You can run unit tests by running:
```
yarn test
```
If you want to run tests only for a specific plugin (to save some time), you can run:
```
yarn test --plugins <plugin>[,<plugin>]* # where <plugin> is "reporting", etc.
```
#### Running server unit tests
You can run mocha unit tests by running:
```
yarn test:mocha
```
For information on testing, see [the Elastic functional test development guide](https://www.elastic.co/guide/en/kibana/current/development-functional-tests.html).
#### Running functional tests
@ -114,7 +81,7 @@ node scripts/functional_tests --config test/security_api_integration/saml.config
Jest integration tests can be used to test behavior with Elasticsearch and the Kibana server.
```sh
node scripts/jest_integration
yarn test:jest_integration
```
An example test exists at [test_utils/jest/integration_tests/example_integration.test.ts](test_utils/jest/integration_tests/example_integration.test.ts)

View file

@ -12,7 +12,7 @@
"build": "../node_modules/.bin/gulp build",
"testonly": "echo 'Deprecated, use `yarn test`'",
"test": "../node_modules/.bin/gulp test",
"test:jest": "node scripts/jest",
"test:jest": "node ../scripts/jest",
"test:mocha": "node scripts/mocha"
},
"kibana": {

View file

@ -7,7 +7,13 @@ Failure to have auth enabled in Kibana will make for a broken UI. UI-based error
### Unit tests
From `~/kibana/x-pack`, run `node scripts/jest.js plugins/beats --watch`.
Run Jest tests:
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
```
yarn test:jest x-pack/plugins/beats --watch
```
### API tests

View file

@ -235,9 +235,12 @@ const migration780 = encryptedSavedObjects.createMigration<RawAlert, RawAlert>(
### Unit tests
From `kibana-root-folder/x-pack`, run:
```bash
$ node scripts/jest.js
Run Jest tests:
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
```
yarn test:jest x-pack/plugins/encrypted_saved_objects --watch
```
### API Integration tests

View file

@ -25,10 +25,10 @@ To debug Kea state in-browser, Kea recommends [Redux Devtools](https://kea.js.or
### Unit tests
From `kibana-root-folder/x-pack`, run:
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
```bash
yarn test:jest plugins/enterprise_search
```
yarn test:jest x-pack/plugins/enterprise_search --watch
```
### E2E tests

View file

@ -53,9 +53,10 @@ public setup(core: CoreSetup, { eventLog }: PluginSetupDependencies) {
### Unit tests
From `kibana-root-folder/x-pack`, run:
```bash
$ node node scripts/jest plugins/event_log
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
```
yarn test:jest x-pack/plugins/event_log --watch
```
### API Integration tests

View file

@ -6,7 +6,7 @@ Graph shows only up in the side bar if your server is running on a platinum or t
## Common commands
* Run tests `node x-pack/scripts/jest.js --watch plugins/graph`
* Run tests `yarn test:jest x-pack/plugins/graph --watch`
* Run type check `node scripts/type_check.js --project=x-pack/tsconfig.json`
* Run linter `node scripts/eslint.js x-pack/plugins/graph`
* Run functional tests (make sure to stop dev server)

View file

@ -4,7 +4,7 @@
Run all tests from the `x-pack` root directory
- Unit tests: `node scripts/jest --watch lens`
- Unit tests: `yarn test:jest x-pack/plugins/lens`
- Functional tests:
- Run `node scripts/functional_tests_server`
- Run `node ../scripts/functional_test_runner.js --config ./test/functional/config.js --grep="lens app"`

View file

@ -7,7 +7,7 @@ Visualize geo data from Elasticsearch or 3rd party geo-services.
Run all tests from the `x-pack` root directory
- Unit tests: `node scripts/jest --watch maps`
- Unit tests: `yarn test:jest x-pack/plugins/maps --watch`
- Functional tests:
- Run `node scripts/functional_tests_server`
- Run `node ../scripts/functional_test_runner.js --config ./test/functional/config.js --grep="maps app"`

View file

@ -68,30 +68,32 @@ These data sets are now ready be analyzed in ML jobs in Kibana.
### Jest tests
Run the test following jest tests from `kibana/x-pack`.
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
Run the test following jest tests from `kibana/x-pack/plugins/ml`.
New snapshots, all plugins:
```
node scripts/jest
yarn test:jest
```
Update snapshots for the ML plugin:
```
node scripts/jest plugins/ml -u
yarn test:jest -u
```
Update snapshots for a specific directory only:
```
node scripts/jest plugins/ml/public/application/settings/filter_lists
yarn test:jest public/application/settings/filter_lists
```
Run tests with verbose output:
```
node scripts/jest plugins/ml --verbose
yarn test:jest --verbose
```
### Functional tests

View file

@ -505,9 +505,11 @@ The task manager's public API is create / delete / list. Updates aren't directly
## Testing
- Unit tests:
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
```
cd x-pack
node scripts/jest --testPathPattern=task_manager --watch
yarn test:jest x-pack/plugins/task_manager --watch
```
- Integration tests:
```

View file

@ -67,30 +67,32 @@ These data sets are now ready to be used for creating transforms in Kibana.
### Jest tests
Run the test following jest tests from `kibana/x-pack`.
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
Run the test following jest tests from `kibana/x-pack/plugins/transform.
New snapshots, all plugins:
```
node scripts/jest
yarn test:jest
```
Update snapshots for the transform plugin:
```
node scripts/jest plugins/transform -u
yarn test:jest -u
```
Update snapshots for a specific directory only:
```
node scripts/jest x-pack/plugins/transform/public/app/sections
yarn test:jest public/app/sections
```
Run tests with verbose output:
```
node scripts/jest plugins/transform --verbose
yarn test:jest --verbose
```
### Functional tests

View file

@ -42,7 +42,11 @@ There's also a `rest_api` folder that defines the structure of the RESTful API e
### Unit tests
From `~/kibana/x-pack`, run `node scripts/jest.js`.
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
```
yarn test:jest x-pack/plugins/uptime
```
### Functional tests

View file

@ -4,15 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
if (process.argv.indexOf('--config') === -1) {
// append correct jest.config if none is provided
const configPath = require('path').resolve(__dirname, '../jest.config.js');
process.argv.push('--config', configPath);
console.log('Running Jest with --config', configPath);
}
if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'test';
}
require('jest').run();
require('@kbn/test').runJest();