Consolidates Jest configuration files and scripts (#82671)

Jest tests are currently organized into main configuration files (src/dev/jest/config.js and x-pack/dev-tools/jest/create_jest_config.js). Both of these are similar, but very slightly due to  previously being in separate repositories. This change consolidates the scripts referenced in those configs and moves them to the `@kbn/test` project.

OSS contained an alias for `test_utils`. Those aliases have been removed in favor of importing these utilities from `@kbn/test/jest`

Blocker to #72569

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
Tyler Smalley 2020-11-12 16:19:56 -08:00 committed by GitHub
parent 452d4c8a8f
commit aba2068291
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
605 changed files with 1110 additions and 2409 deletions

View file

@ -11,6 +11,7 @@
"kbn:watch": "rm -rf target && ../../node_modules/.bin/tsc --watch"
},
"dependencies": {
"@kbn/dev-utils": "link:../kbn-dev-utils"
"@kbn/dev-utils": "link:../kbn-dev-utils",
"@kbn/test": "link:../kbn-test"
}
}

View file

@ -29,7 +29,6 @@ exports.getWebpackConfig = function (kibanaPath) {
alias: {
// Dev defaults for test bundle https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/core_plugins/tests_bundle/index.js#L73-L78
fixtures: resolve(kibanaPath, 'src/fixtures'),
test_utils: resolve(kibanaPath, 'src/test_utils/public'),
},
unsafeCache: true,
},

View file

@ -391,7 +391,7 @@ Testing React component that uses the `injectI18n` higher-order component is mor
With shallow rendering only top level component is rendered, that is a wrapper itself, not the original component. Since we want to test the rendering of the original component, we need to access it via the wrapper's `WrappedComponent` property. Its value will be the component we passed into `injectI18n()`.
When testing such component, use the `shallowWithIntl` helper function defined in `test_utils/enzyme_helpers` and pass the component's `WrappedComponent` property to render the wrapped component. This will shallow render the component with Enzyme and inject the necessary context and props to use the `intl` mock defined in `test_utils/mocks/intl`.
When testing such component, use the `shallowWithIntl` helper function defined in `@kbn/test/jest` and pass the component's `WrappedComponent` property to render the wrapped component. This will shallow render the component with Enzyme and inject the necessary context and props to use the `intl` mock defined in `test_utils/mocks/intl`.
Use the `mountWithIntl` helper function to mount render the component.

View file

@ -0,0 +1,111 @@
/*
* 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.
*/
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
const { resolve } = require('path');
module.exports = {
// The directory where Jest should output its coverage files
coverageDirectory: '<rootDir>/target/kibana-coverage/jest',
// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'],
// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: !!process.env.CODE_COVERAGE ? ['json'] : ['html', 'text'],
// An array of file extensions your modules use
moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
'@elastic/eui/lib/(.*)?': '<rootDir>/node_modules/@elastic/eui/test-env/$1',
'@elastic/eui$': '<rootDir>/node_modules/@elastic/eui/test-env',
'\\.module.(css|scss)$': '<rootDir>/packages/kbn-test/target/jest/mocks/css_module_mock.js',
'\\.(css|less|scss)$': '<rootDir>/packages/kbn-test/target/jest/mocks/style_mock.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/packages/kbn-test/target/jest/mocks/file_mock.js',
'\\.ace\\.worker.js$': '<rootDir>/packages/kbn-test/target/jest/mocks/worker_module_mock.js',
'\\.editor\\.worker.js$': '<rootDir>/packages/kbn-test/target/jest/mocks/worker_module_mock.js',
'^(!!)?file-loader!': '<rootDir>/packages/kbn-test/target/jest/mocks/file_mock.js',
'^fixtures/(.*)': '<rootDir>/src/fixtures/$1',
'^src/core/(.*)': '<rootDir>/src/core/$1',
'^src/legacy/(.*)': '<rootDir>/src/legacy/$1',
'^src/plugins/(.*)': '<rootDir>/src/plugins/$1',
},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
modulePathIgnorePatterns: ['__fixtures__/', 'target/'],
// Use this configuration option to add custom reporters to Jest
reporters: ['default', resolve(__dirname, './target/jest/junit_reporter')],
// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: [
'<rootDir>/packages/kbn-test/target/jest/setup/babel_polyfill.js',
'<rootDir>/packages/kbn-test/target/jest/setup/polyfills.js',
'<rootDir>/packages/kbn-test/target/jest/setup/enzyme.js',
],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: [
'<rootDir>/packages/kbn-test/target/jest/setup/setup_test.js',
'<rootDir>/packages/kbn-test/target/jest/setup/mocks.js',
'<rootDir>/packages/kbn-test/target/jest/setup/react_testing_library.js',
],
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
snapshotSerializers: [
'<rootDir>/src/plugins/kibana_react/public/util/test_helpers/react_mount_serializer.ts',
'<rootDir>/node_modules/enzyme-to-json/serializer',
],
// The test environment that will be used for testing
testEnvironment: 'jest-environment-jsdom-thirteen',
// The glob patterns Jest uses to detect test files
testMatch: ['**/*.test.{js,mjs,ts,tsx}'],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
'<rootDir>/packages/kbn-ui-framework/(dist|doc_site|generator-kui)/',
'<rootDir>/packages/kbn-pm/dist/',
`integration_tests/`,
],
// This option allows use of a custom test runner
testRunner: 'jest-circus/runner',
// A map from regular expressions to paths to transformers
transform: {
'^.+\\.(js|tsx?)$': '<rootDir>/packages/kbn-test/target/jest/babel_transform.js',
'^.+\\.txt?$': 'jest-raw-loader',
'^.+\\.html?$': 'jest-raw-loader',
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: [
// ignore all node_modules except monaco-editor which requires babel transforms to handle dynamic import()
// since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842)
'[/\\\\]node_modules(?![\\/\\\\]monaco-editor)[/\\\\].+\\.js$',
'packages/kbn-pm/dist/index.js',
],
};

View file

@ -0,0 +1,4 @@
{
"main": "../target/jest",
"types": "../target/types/jest/index.d.ts"
}

View file

@ -5,16 +5,22 @@
"license": "Apache-2.0",
"main": "./target/index.js",
"scripts": {
"build": "../../node_modules/.bin/babel src --out-dir target --delete-dir-on-start --extensions .ts,.js,.tsx --ignore *.test.js,**/__tests__/** --source-maps=inline",
"kbn:bootstrap": "yarn build",
"kbn:watch": "yarn build --watch"
"build": "node scripts/build",
"kbn:bootstrap": "node scripts/build --source-maps",
"kbn:watch": "node scripts/build --watch --source-maps"
},
"kibana": {
"devOnly": true
},
"dependencies": {
"@kbn/es": "link:../kbn-es",
"@kbn/i18n": "link:../kbn-i18n",
"@kbn/optimizer": "link:../kbn-optimizer"
},
"devDependencies": {
"@kbn/babel-preset": "link:../kbn-babel-preset",
"@kbn/dev-utils": "link:../kbn-dev-utils",
"@kbn/expect": "link:../kbn-expect",
"@kbn/utils": "link:../kbn-utils"
}
}

View file

@ -0,0 +1,91 @@
/*
* 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.
*/
const { resolve } = require('path');
const del = require('del');
const supportsColor = require('supports-color');
const { run, withProcRunner } = require('@kbn/dev-utils');
const ROOT_DIR = resolve(__dirname, '..');
const BUILD_DIR = resolve(ROOT_DIR, 'target');
const padRight = (width, str) =>
str.length >= width ? str : `${str}${' '.repeat(width - str.length)}`;
run(
async ({ log, flags }) => {
await withProcRunner(log, async (proc) => {
log.info('Deleting old output');
await del(BUILD_DIR);
const cwd = ROOT_DIR;
const env = { ...process.env };
if (supportsColor.stdout) {
env.FORCE_COLOR = 'true';
}
log.info(`Starting babel and typescript${flags.watch ? ' in watch mode' : ''}`);
await Promise.all([
proc.run(padRight(10, `babel`), {
cmd: 'babel',
args: [
'src',
'--config-file',
require.resolve('../babel.config.js'),
'--out-dir',
BUILD_DIR,
'--extensions',
'.ts,.js,.tsx',
...(flags.watch ? ['--watch'] : ['--quiet']),
...(!flags['source-maps'] || !!process.env.CODE_COVERAGE
? []
: ['--source-maps', 'inline']),
],
wait: true,
env,
cwd,
}),
proc.run(padRight(10, 'tsc'), {
cmd: 'tsc',
args: [
...(flags.watch ? ['--watch', '--preserveWatchOutput', 'true'] : []),
...(flags['source-maps'] ? ['--declarationMap', 'true'] : []),
],
wait: true,
env,
cwd,
}),
]);
log.success('Complete');
});
},
{
description: 'Simple build tool for @kbn/i18n package',
flags: {
boolean: ['watch', 'source-maps'],
help: `
--watch Run in watch mode
--source-maps Include sourcemaps
`,
},
}
);

View file

@ -58,5 +58,3 @@ export { runFailedTestsReporterCli } from './failed_tests_reporter';
export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';
export * from './functional_test_runner';
export * from './jest';

View file

@ -17,6 +17,4 @@
* under the License.
*/
export * from './junit_reporter';
export * from './report_path';
export * from './utils';

View file

@ -24,7 +24,7 @@ import { readFileSync } from 'fs';
import del from 'del';
import execa from 'execa';
import xml2js from 'xml2js';
import { getUniqueJunitReportPath } from '@kbn/test';
import { getUniqueJunitReportPath } from '../../report_path';
import { REPO_ROOT } from '@kbn/utils';
const MINUTE = 1000 * 60;

View file

@ -27,7 +27,7 @@ import type { Config } from '@jest/types';
import { AggregatedResult, Test, BaseReporter } from '@jest/reporters';
import { escapeCdata } from '../mocha/xml';
import { getUniqueJunitReportPath } from './report_path';
import { getUniqueJunitReportPath } from '../report_path';
interface ReporterOptions {
reportName?: string;

View file

@ -28,3 +28,11 @@ const MutationObserver = require('mutation-observer');
Object.defineProperty(window, 'MutationObserver', { value: MutationObserver });
require('whatwg-fetch');
if (!global.URL.hasOwnProperty('createObjectURL')) {
Object.defineProperty(global.URL, 'createObjectURL', { value: () => '' });
}
// Will be replaced with a better solution in EUI
// https://github.com/elastic/eui/issues/3713
global._isJest = true;

View file

@ -17,17 +17,14 @@
* under the License.
*/
export { findTestSubject } from './find_test_subject';
export function test(value: any) {
return value && value.__reactMount__;
}
export { WithStore } from './redux_helpers';
export { WithMemoryRouter, WithRoute, reactRouterMock } from './router_helpers';
export * from './utils';
export {
setSVGElementGetBBox,
setHTMLElementOffset,
setHTMLElementClientSizes,
setSVGElementGetComputedTextLength,
} from './jsdom_svg_mocks';
export function print(value: any, serialize: any) {
// there is no proper way to correctly indent multiline values
// so the trick here is to use the Object representation and rewriting the root object name
return serialize({
reactNode: value.__reactMount__,
}).replace('Object', 'MountPoint');
}

View file

@ -17,9 +17,10 @@
* under the License.
*/
export {
setSVGElementGetBBox,
setHTMLElementOffset,
setHTMLElementClientSizes,
setSVGElementGetComputedTextLength,
} from './helpers';
/*
Global import, so we don't need to remember to import the lib in each file
https://www.npmjs.com/package/jest-styled-components#global-installation
*/
import 'jest-styled-components';
import '@testing-library/jest-dom';

View file

@ -1,7 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
* 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.
*/
/**
@ -192,4 +205,14 @@ export const mountHook = <Args extends {}, HookValue extends any>(
};
};
export const nextTick = () => new Promise((res) => process.nextTick(res));
export function shallowWithI18nProvider<T>(child: ReactElement<T>) {
const wrapped = shallow(<I18nProvider>{child}</I18nProvider>);
const name = typeof child.type === 'string' ? child.type : child.type.name;
return wrapped.find(name).dive();
}
export function mountWithI18nProvider<T>(child: ReactElement<T>) {
const wrapped = mount(<I18nProvider>{child}</I18nProvider>);
const name = typeof child.type === 'string' ? child.type : child.type.name;
return wrapped.find(name);
}

View file

@ -0,0 +1,66 @@
/*
* 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 { getUrl } from './get_url';
describe('getUrl', function () {
it('should convert to a url', function () {
const url = getUrl(
{
protocol: 'http',
hostname: 'localhost',
},
{
pathname: 'foo',
}
);
expect(url).toBe('http://localhost/foo');
});
it('should convert to a url with port', function () {
const url = getUrl(
{
protocol: 'http',
hostname: 'localhost',
port: 9220,
},
{
pathname: 'foo',
}
);
expect(url).toBe('http://localhost:9220/foo');
});
it('should convert to a secure hashed url', function () {
expect(
getUrl(
{
protocol: 'https',
hostname: 'localhost',
},
{
pathname: 'foo',
hash: 'bar',
}
)
).toBe('https://localhost/foo#bar');
});
});

View file

@ -0,0 +1,75 @@
/*
* 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 _ from 'lodash';
import url from 'url';
interface UrlParam {
hash?: string;
host?: string;
hostname?: string;
href?: string;
password?: string;
pathname?: string;
port?: number;
protocol?: string;
search?: string;
username?: string;
}
interface App {
pathname?: string;
hash?: string;
}
/**
* Converts a config and a pathname to a url
* @param {object} config A url config
* example:
* {
* protocol: 'http',
* hostname: 'localhost',
* port: 9220,
* auth: kibanaTestUser.username + ':' + kibanaTestUser.password
* }
* @param {object} app The params to append
* example:
* {
* pathname: 'app/kibana',
* hash: '/discover'
* }
* @return {string}
*/
function getUrl(config: UrlParam, app: App) {
return url.format(_.assign({}, config, app));
}
getUrl.noAuth = function getUrlNoAuth(config: UrlParam, app: App) {
config = _.pickBy(config, function (val, param) {
return param !== 'auth';
});
return getUrl(config, app);
};
getUrl.baseUrl = function getBaseUrl(config: UrlParam) {
return url.format(_.pick(config, 'protocol', 'hostname', 'port'));
};
export { getUrl };

View file

@ -0,0 +1,40 @@
/*
* 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.
*/
export * from './enzyme_helpers';
export * from './find_test_subject';
export * from './jsdom_svg_mocks';
export * from './random';
export * from './redux_helpers';
export * from './router_helpers';
export * from './stub_browser_storage';
export * from './stub_web_worker';
export * from './testbed';
export const nextTick = () => new Promise((res) => process.nextTick(res));
export const delay = (time = 0) => new Promise((resolve) => setTimeout(resolve, time));

View file

@ -22,8 +22,6 @@ import Chance from 'chance';
const chance = new Chance();
const CHARS_POOL = 'abcdefghijklmnopqrstuvwxyz';
export const nextTick = (time = 0) => new Promise((resolve) => setTimeout(resolve, time));
export const getRandomNumber = (range: { min: number; max: number } = { min: 1, max: 20 }) =>
chance.integer(range);

View file

@ -29,9 +29,10 @@ export const WithMemoryRouter = (initialEntries: string[] = ['/'], initialIndex:
</MemoryRouter>
);
export const WithRoute = (componentRoutePath = '/', onRouter = (router: any) => {}) => (
WrappedComponent: ComponentType
) => {
export const WithRoute = (
componentRoutePath: string | string[] = '/',
onRouter = (router: any) => {}
) => (WrappedComponent: ComponentType) => {
// Create a class component that will catch the router
// and forward it to our "onRouter()" handler.
const CatchRouter = withRouter(

View file

@ -0,0 +1,36 @@
/*
* 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.
*/
function stubWebWorker() {
if (!window.Worker) {
// @ts-ignore we aren't honoring the real Worker spec here
window.Worker = function Worker() {
this.postMessage = jest.fn();
// @ts-ignore TypeScript doesn't think this exists on the Worker interface
// https://developer.mozilla.org/en-US/docs/Web/API/Worker/terminate
this.terminate = jest.fn();
};
}
}
stubWebWorker();
// Add an export to avoid TS complaining "stub_web_worker.ts" is not a module.
export { stubWebWorker };

View file

@ -138,25 +138,6 @@ In order to prevent flakiness in component integration tests, please consider th
component.update();
```
## Chrome extension
There is a small Chrome extension that you can install in order to track the test subjects on the current page. As it is meant to be used
during development, the extension is only active when navigating to a `localhost` URL.
You will find the "Test subjects finder" extension in the `x-pack/test_utils/chrome_extension` folder.
### Install the extension
- open the "extensions" window in Chrome
- activate the "Developer mode" (top right corner)
- drag and drop the `test_subjects_finder` folder on the window.
You can specify a DOM node (the tree "root") from which the test subjects will be found. If you don't specify any, the document `<body>` will be used. The output format can either be `Typescript` (to export a string union type) or `List`.
### Output
Once you start tracking the test subjects on the page, the output will be printed in the **Chrome dev console**.
## API
## `registerTestBed(Component [, testBedConfig])`

View file

@ -23,7 +23,8 @@ import { ReactWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { mountWithIntl } from '../enzyme_helpers';
import { WithMemoryRouter, WithRoute, WithStore } from '../helpers';
import { WithMemoryRouter, WithRoute } from '../router_helpers';
import { WithStore } from '../redux_helpers';
import { MemoryRouterConfig } from './types';
interface Config {

View file

@ -1,7 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
* 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 { ComponentType, ReactWrapper } from 'enzyme';
@ -31,7 +44,7 @@ const defaultConfig: TestBedConfig = {
*
* @example
```typescript
import { registerTestBed } from '../../../../test_utils';
import { registerTestBed } from '@kbn/test/jest';
import { RemoteClusterList } from '../../app/sections/remote_cluster_list';
import { remoteClustersStore } from '../../app/store';

View file

@ -74,6 +74,7 @@ export interface TestBed<T = string> {
* and we need to wait for the data to be fetched (and bypass any "loading" state).
*/
waitFor: (testSubject: T, count?: number) => Promise<void>;
waitForFn: (predicate: () => Promise<boolean>, errMessage: string) => Promise<void>;
form: {
/**
* Set the value of a form text input.
@ -175,7 +176,7 @@ export interface MemoryRouterConfig {
/** The React Router **initial index** setting ([see documentation](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/MemoryRouter.md)) */
initialIndex?: number;
/** The route **path** for the mounted component (defaults to `"/"`) */
componentRoutePath?: string;
componentRoutePath?: string | string[];
/** A callBack that will be called with the React Router instance once mounted */
onRouter?: (router: any) => void;
}

View file

@ -25,7 +25,7 @@ import { parseString } from 'xml2js';
import del from 'del';
import Mocha from 'mocha';
import expect from '@kbn/expect';
import { getUniqueJunitReportPath } from '@kbn/test';
import { getUniqueJunitReportPath } from '../../report_path';
import { setupJUnitReportGeneration } from '../junit_report_generation';

View file

@ -22,7 +22,7 @@ import { writeFileSync, mkdirSync } from 'fs';
import { inspect } from 'util';
import xmlBuilder from 'xmlbuilder';
import { getUniqueJunitReportPath } from '@kbn/test';
import { getUniqueJunitReportPath } from '../report_path';
import { getSnapshotOfRunnableLogs } from './log_cache';
import { escapeCdata } from '../';

View file

@ -20,7 +20,7 @@
import Fs from 'fs';
import Path from 'path';
import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix';
import { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';
export function getUniqueJunitReportPath(
rootDirectory: string,

View file

@ -1,11 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"tsBuildInfoFile": "../../build/tsbuildinfo/packages/kbn-test"
},
"include": [
"types/**/*",
"src/**/*",
"index.d.ts"
]
],
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./target/types",
"types": [
"jest",
"node"
],
"stripInternal": true,
"declarationMap": true
}
}

View file

@ -21,7 +21,7 @@ import { mount, ReactWrapper } from 'enzyme';
import React from 'react';
import { BehaviorSubject } from 'rxjs';
import sinon from 'sinon';
import { StubBrowserStorage } from 'test_utils/stub_browser_storage';
import { StubBrowserStorage } from '@kbn/test/jest';
import { ChromeNavLink, DEFAULT_APP_CATEGORIES } from '../../..';
import { httpServiceMock } from '../../../http/http_service.mock';
import { ChromeRecentlyAccessedHistoryItem } from '../../recently_accessed';

View file

@ -20,11 +20,10 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
import { BehaviorSubject } from 'rxjs';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { StubBrowserStorage, mountWithIntl } from '@kbn/test/jest';
import { httpServiceMock } from '../../../http/http_service.mock';
import { applicationServiceMock } from '../../../mocks';
import { Header } from './header';
import { StubBrowserStorage } from 'test_utils/stub_browser_storage';
jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => () => 'mockId',

View file

@ -21,7 +21,7 @@ import { EuiCallOut } from '@elastic/eui';
import testSubjSelector from '@kbn/test-subj-selector';
import React from 'react';
import * as Rx from 'rxjs';
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest';
import { FatalErrorsScreen } from './fatal_errors_screen';

View file

@ -19,7 +19,7 @@
import { shallow } from 'enzyme';
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { ErrorToast } from './error_toast';

View file

@ -17,6 +17,7 @@
* under the License.
*/
import preset from '@kbn/test/jest-preset';
import config from './config';
export default {
@ -26,7 +27,7 @@ export default {
'**/integration_tests/**/*.test.ts',
'**/integration_tests/**/*.test.tsx',
],
testPathIgnorePatterns: config.testPathIgnorePatterns.filter(
testPathIgnorePatterns: preset.testPathIgnorePatterns.filter(
(pattern) => !pattern.includes('integration_tests')
),
reporters: [
@ -36,5 +37,5 @@ export default {
{ reportName: 'Jest Integration Tests' },
],
],
setupFilesAfterEnv: ['<rootDir>/src/dev/jest/setup/after_env.integration.js'],
setupFilesAfterEnv: ['<rootDir>/packages/kbn-test/target/jest/setup/after_env.integration.js'],
};

View file

@ -17,9 +17,8 @@
* under the License.
*/
import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../constants';
export default {
preset: '@kbn/test',
rootDir: '../../..',
roots: [
'<rootDir>/src/plugins',
@ -51,53 +50,5 @@ export default {
'!packages/kbn-ui-framework/src/services/index.js',
'!packages/kbn-ui-framework/src/services/**/*/index.js',
],
moduleNameMapper: {
'@elastic/eui$': '<rootDir>/node_modules/@elastic/eui/test-env',
'@elastic/eui/lib/(.*)?': '<rootDir>/node_modules/@elastic/eui/test-env/$1',
'^src/plugins/(.*)': '<rootDir>/src/plugins/$1',
'^test_utils/(.*)': '<rootDir>/src/test_utils/public/$1',
'^fixtures/(.*)': '<rootDir>/src/fixtures/$1',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/src/dev/jest/mocks/file_mock.js',
'\\.(css|less|scss)$': '<rootDir>/src/dev/jest/mocks/style_mock.js',
'\\.ace\\.worker.js$': '<rootDir>/src/dev/jest/mocks/worker_module_mock.js',
'\\.editor\\.worker.js$': '<rootDir>/src/dev/jest/mocks/worker_module_mock.js',
'^(!!)?file-loader!': '<rootDir>/src/dev/jest/mocks/file_mock.js',
},
setupFiles: [
'<rootDir>/src/dev/jest/setup/babel_polyfill.js',
'<rootDir>/src/dev/jest/setup/polyfills.js',
'<rootDir>/src/dev/jest/setup/enzyme.js',
],
setupFilesAfterEnv: [
'<rootDir>/src/dev/jest/setup/mocks.js',
'<rootDir>/src/dev/jest/setup/react_testing_library.js',
],
coverageDirectory: '<rootDir>/target/kibana-coverage/jest',
coverageReporters: !!process.env.CODE_COVERAGE ? ['json'] : ['html', 'text'],
moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'],
modulePathIgnorePatterns: ['__fixtures__/', 'target/'],
testEnvironment: 'jest-environment-jsdom-thirteen',
testMatch: ['**/*.test.{js,mjs,ts,tsx}'],
testPathIgnorePatterns: [
'<rootDir>/packages/kbn-ui-framework/(dist|doc_site|generator-kui)/',
'<rootDir>/packages/kbn-pm/dist/',
`${RESERVED_DIR_JEST_INTEGRATION_TESTS}/`,
],
transform: {
'^.+\\.(js|tsx?)$': '<rootDir>/src/dev/jest/babel_transform.js',
'^.+\\.txt?$': 'jest-raw-loader',
'^.+\\.html?$': 'jest-raw-loader',
},
transformIgnorePatterns: [
// ignore all node_modules except monaco-editor which requires babel transforms to handle dynamic import()
// since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842)
'[/\\\\]node_modules(?![\\/\\\\]monaco-editor)[/\\\\].+\\.js$',
'packages/kbn-pm/dist/index.js',
],
snapshotSerializers: [
'<rootDir>/src/plugins/kibana_react/public/util/test_helpers/react_mount_serializer.ts',
'<rootDir>/node_modules/enzyme-to-json/serializer',
],
reporters: ['default', '<rootDir>/packages/kbn-test/target/jest/junit_reporter'],
testRunner: 'jasmine2',
};

View file

@ -49,6 +49,7 @@ export const IGNORE_FILE_GLOBS = [
'Dockerfile*',
'vars/*',
'.ci/pipeline-library/**/*',
'packages/kbn-test/jest-preset.js',
// filename must match language code which requires capital letters
'**/translations/*.json',

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
import { shallowWithI18nProvider } from '@kbn/test/jest';
import { PageFooter } from './page_footer';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
import { shallowWithI18nProvider } from '@kbn/test/jest';
import { PageSubtitle } from './page_subtitle';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
import { shallowWithI18nProvider } from '@kbn/test/jest';
import { PageTitle } from './page_title';

View file

@ -20,7 +20,7 @@
import React from 'react';
import { Observable } from 'rxjs';
import { ReactWrapper } from 'enzyme';
import { mountWithI18nProvider } from 'test_utils/enzyme_helpers';
import { mountWithI18nProvider } from '@kbn/test/jest';
import dedent from 'dedent';
import {
PublicUiSettingsParams,

View file

@ -19,7 +19,7 @@
import React from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers';
import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest';
import { mount, ReactWrapper } from 'enzyme';
import { FieldSetting } from '../../types';
import { UiSettingsType, StringValidation } from '../../../../../../core/public';

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers';
import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest';
import { UiSettingsType } from '../../../../../../core/public';
import { findTestSubject } from '@elastic/eui/lib/test';

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers';
import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';

View file

@ -27,7 +27,7 @@ import * as sinon from 'sinon';
import { serviceContextMock } from '../../../../contexts/services_context.mock';
import { nextTick } from 'test_utils/enzyme_helpers';
import { nextTick } from '@kbn/test/jest';
import {
ServicesContextProvider,
EditorContextProvider,

View file

@ -20,7 +20,7 @@
import React from 'react';
import { DashboardContainer } from '..';
import { isErrorEmbeddable } from '../../embeddable_plugin';
import { mountWithIntl } from '../../../../../test_utils/public/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
import { getSampleDashboardInput } from '../test_helpers';
import {

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen';
import { findTestSubject } from '@elastic/eui/lib/test';
import { coreMock } from '../../../../core/public/mocks';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { nextTick } from 'test_utils/enzyme_helpers';
import { nextTick } from '@kbn/test/jest';
import { isErrorEmbeddable, ViewMode } from '../../embeddable_plugin';
import { DashboardContainer, DashboardContainerOptions } from './dashboard_container';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';

View file

@ -21,7 +21,7 @@
import sizeMe from 'react-sizeme';
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { skip } from 'rxjs/operators';
import { DashboardGrid, DashboardGridProps } from './dashboard_grid';
import { DashboardContainer, DashboardContainerOptions } from '../dashboard_container';

View file

@ -22,7 +22,7 @@ import React from 'react';
import { skip } from 'rxjs/operators';
import { mount } from 'enzyme';
import { I18nProvider } from '@kbn/i18n/react';
import { nextTick } from 'test_utils/enzyme_helpers';
import { nextTick } from '@kbn/test/jest';
import { DashboardViewport, DashboardViewportProps } from './dashboard_viewport';
import { DashboardContainer, DashboardContainerOptions } from '../dashboard_container';
import { getSampleDashboardInput } from '../../test_helpers';

View file

@ -20,7 +20,7 @@
import { findTestSubject } from '@elastic/eui/lib/test';
import React from 'react';
import { mount } from 'enzyme';
import { nextTick } from 'test_utils/enzyme_helpers';
import { nextTick } from '@kbn/test/jest';
import { I18nProvider } from '@kbn/i18n/react';
import { ViewMode, CONTEXT_MENU_TRIGGER, EmbeddablePanel } from '../../embeddable_plugin';
import { DashboardContainer, DashboardContainerOptions } from '../embeddable/dashboard_container';

View file

@ -19,7 +19,7 @@
import React from 'react';
import sinon from 'sinon';
import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers';
import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';
import { DashboardCloneModal } from './clone_modal';

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
import { shallowWithI18nProvider } from '@kbn/test/jest';
jest.mock('../../../../saved_objects/public', () => ({
SavedObjectSaveModal: () => null,

View file

@ -19,7 +19,7 @@
import { QueryStringManager } from './query_string_manager';
import { Storage } from '../../../../kibana_utils/public/storage';
import { StubBrowserStorage } from 'test_utils/stub_browser_storage';
import { StubBrowserStorage } from '@kbn/test/jest';
import { coreMock } from '../../../../../core/public/mocks';
import { Query } from '../../../common/query';

View file

@ -24,7 +24,7 @@ import { Filter, FilterStateStore, UI_SETTINGS } from '../../../common';
import { coreMock } from '../../../../../core/public/mocks';
import { BaseStateContainer, createStateContainer, Storage } from '../../../../kibana_utils/public';
import { QueryService, QueryStart } from '../query_service';
import { StubBrowserStorage } from '../../../../../test_utils/public/stub_browser_storage';
import { StubBrowserStorage } from '@kbn/test/jest';
import { connectToQueryState } from './connect_to_query_state';
import { TimefilterContract } from '../timefilter';
import { QueryState } from './types';

View file

@ -29,7 +29,7 @@ import {
Storage,
} from '../../../../kibana_utils/public';
import { QueryService, QueryStart } from '../query_service';
import { StubBrowserStorage } from 'test_utils/stub_browser_storage';
import { StubBrowserStorage } from '@kbn/test/jest';
import { TimefilterContract } from '../timefilter';
import { syncQueryStateWithUrl } from './sync_state_with_url';
import { QueryState } from './types';

View file

@ -21,7 +21,7 @@ import React from 'react';
import { QueryLanguageSwitcher } from './language_switcher';
import { KibanaContextProvider } from 'src/plugins/kibana_react/public';
import { coreMock } from '../../../../../core/public/mocks';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { EuiButtonEmpty, EuiPopover } from '@elastic/eui';
const startMock = coreMock.createStart();

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { mountWithIntl as mount } from 'test_utils/enzyme_helpers';
import { mountWithIntl as mount } from '@kbn/test/jest';
import { NoDataPopover } from './no_data_popover';
import { EuiTourStep } from '@elastic/eui';
import { act } from 'react-dom/test-utils';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { shallowWithIntl } from '@kbn/test/jest';
import { ShardFailureDescription } from './shard_failure_description';
import { shardFailureResponse } from './__mocks__/shard_failure_response';
import { ShardFailure } from './shard_failure_types';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { shallowWithIntl } from '@kbn/test/jest';
import { ShardFailureModal } from './shard_failure_modal';
import { shardFailureRequest } from './__mocks__/shard_failure_request';
import { shardFailureResponse } from './__mocks__/shard_failure_response';

View file

@ -18,7 +18,7 @@
*/
import { openModal } from './shard_failure_open_modal_button.test.mocks';
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import ShardFailureOpenModalButton from './shard_failure_open_modal_button';
import { shardFailureRequest } from './__mocks__/shard_failure_request';
import { shardFailureResponse } from './__mocks__/shard_failure_response';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { shallowWithIntl } from '@kbn/test/jest';
import { ShardFailureTable } from './shard_failure_table';
import { shardFailureResponse } from './__mocks__/shard_failure_response';
import { ShardFailure } from './shard_failure_types';

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { ActionBar, ActionBarProps } from './action_bar';
import { findTestSubject } from '@elastic/eui/lib/test';
import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../query_parameters/constants';

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest';
import { ToolBarPagerButtons } from './tool_bar_pager_buttons';
import { findTestSubject } from '@elastic/eui/lib/test';

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { renderWithIntl } from 'test_utils/enzyme_helpers';
import { renderWithIntl } from '@kbn/test/jest';
import { ToolBarPagerText } from './tool_bar_pager_text';
test('it renders ToolBarPagerText without crashing', () => {

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { TableHeader } from './table_header';
import { findTestSubject } from '@elastic/eui/lib/test';
import { SortOrder } from './helpers';

View file

@ -20,7 +20,7 @@
import React from 'react';
import { ContextAppLegacy } from './context_app_legacy';
import { IIndexPattern } from '../../../../../data/common/index_patterns';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { DocTableLegacy } from '../../angular/doc_table/create_doc_table_react';
import { findTestSubject } from '@elastic/eui/lib/test';
import { ActionBar } from '../../angular/context/components/action_bar/action_bar';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { ReactWrapper } from 'enzyme';
import { ContextErrorMessage } from './context_error_message';
// @ts-ignore

View file

@ -19,7 +19,7 @@
import { throwError, of } from 'rxjs';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { ReactWrapper } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';
import { Doc, DocProps } from './doc';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { ReactWrapper } from 'enzyme';
import { HitsCounter, HitsCounterProps } from './hits_counter';
import { findTestSubject } from '@elastic/eui/lib/test';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { ReactWrapper } from 'enzyme';
import { LoadingSpinner } from './loading_spinner';
import { findTestSubject } from '@elastic/eui/lib/test';

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';
import { DiscoverNoResults, DiscoverNoResultsProps } from './no_results';

View file

@ -21,7 +21,7 @@ import React from 'react';
import { findTestSubject } from '@elastic/eui/lib/test';
// @ts-ignore
import stubbedLogstashFields from 'fixtures/logstash_fields';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { DiscoverField } from './discover_field';
import { coreMock } from '../../../../../../core/public/mocks';
import { IndexPatternField } from '../../../../../data/public';

View file

@ -21,7 +21,7 @@ import React from 'react';
import { findTestSubject } from '@elastic/eui/lib/test';
// @ts-ignore
import stubbedLogstashFields from 'fixtures/logstash_fields';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { DiscoverFieldDetails } from './discover_field_details';
import { coreMock } from '../../../../../../core/public/mocks';
import { IndexPatternField } from '../../../../../data/public';

View file

@ -18,7 +18,7 @@
*/
import React, { EventHandler, MouseEvent as ReactMouseEvent } from 'react';
import { act } from 'react-dom/test-utils';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';
import { DiscoverFieldSearch, Props } from './discover_field_search';
import { EuiButtonGroupProps, EuiPopover } from '@elastic/eui';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { shallowWithIntl as shallow } from 'test_utils/enzyme_helpers';
import { shallowWithIntl as shallow } from '@kbn/test/jest';
// @ts-ignore
import { ShallowWrapper } from 'enzyme';

View file

@ -24,7 +24,7 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import realHits from 'fixtures/real_hits.js';
// @ts-ignore
import stubbedLogstashFields from 'fixtures/logstash_fields';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import React from 'react';
import { DiscoverSidebar, DiscoverSidebarProps } from './discover_sidebar';
import { coreMock } from '../../../../../../core/public/mocks';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { ReactWrapper } from 'enzyme';
import { SkipBottomButton, SkipBottomButtonProps } from './skip_bottom_button';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
import { ReactWrapper } from 'enzyme';
import { TimechartHeader, TimechartHeaderProps } from './timechart_header';
import { EuiIconTip } from '@elastic/eui';

View file

@ -18,7 +18,7 @@
*/
import React from 'react';
import { nextTick } from 'test_utils/enzyme_helpers';
import { nextTick } from '@kbn/test/jest';
import { EmbeddableChildPanel } from './embeddable_child_panel';
import { CONTACT_CARD_EMBEDDABLE } from '../test_samples/embeddables/contact_card/contact_card_embeddable_factory';
import { SlowContactCardEmbeddableFactory } from '../test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory';

View file

@ -19,7 +19,7 @@
import React from 'react';
import { mount } from 'enzyme';
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
import { mountWithIntl, nextTick } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';
import { I18nProvider } from '@kbn/i18n/react';

View file

@ -27,7 +27,7 @@ import {
import { HelloWorldContainer } from '../../../../test_samples/embeddables/hello_world_container';
import { ContactCardEmbeddable } from '../../../../test_samples/embeddables/contact_card/contact_card_embeddable';
import { ContainerInput } from '../../../../containers';
import { mountWithIntl as mount } from 'test_utils/enzyme_helpers';
import { mountWithIntl as mount } from '@kbn/test/jest';
import { ReactWrapper } from 'enzyme';
import { coreMock } from '../../../../../../../../core/public/mocks';
import { findTestSubject } from '@elastic/eui/lib/test';

View file

@ -20,7 +20,7 @@ import React from 'react';
import { SavedObjectFinderCreateNew } from '../saved_object_finder_create_new';
import { shallow } from 'enzyme';
import { EuiButton, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '@elastic/eui';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
describe('SavedObjectFinderCreateNew', () => {
test('renders correctly with no items', () => {

View file

@ -18,7 +18,7 @@
*/
import { Container, isErrorEmbeddable } from '../../../..';
import { nextTick } from 'test_utils/enzyme_helpers';
import { nextTick } from '@kbn/test/jest';
import { CustomizePanelTitleAction } from './customize_panel_action';
import {
ContactCardEmbeddable,

View file

@ -35,7 +35,7 @@ import { testPlugin } from './test_plugin';
import { CustomizePanelModal } from '../lib/panel/panel_header/panel_actions/customize_title/customize_panel_modal';
import { EmbeddableStart } from '../plugin';
import { createEmbeddablePanelMock } from '../mocks';
import { mountWithIntl } from '../../../../test_utils/public/enzyme_helpers';
import { mountWithIntl } from '@kbn/test/jest';
let api: EmbeddableStart;
let container: Container;

Some files were not shown because too many files have changed in this diff Show more