mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Upgrade to Jest 29 (#143319)
https://jestjs.io/blog/2022/04/25/jest-28 https://jestjs.io/blog/2022/08/25/jest-29 - jest.useFakeTimers('legacy') -> jest.useFakeTimers({ legacyFakeTimers: true }); - jest.useFakeTimers('modern'); -> jest.useFakeTimers(); - tests can either use promises or callbacks, but not both - test runner jasmine is no longer included, switch all suites to jest-circus Co-authored-by: Andrew Tate <andrew.tate@elastic.co>
This commit is contained in:
parent
ab2eb9db28
commit
2ac7ebe3bf
264 changed files with 1314 additions and 983 deletions
36
package.json
36
package.json
|
@ -716,9 +716,9 @@
|
|||
"@emotion/jest": "^11.10.0",
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
||||
"@istanbuljs/schema": "^0.1.2",
|
||||
"@jest/console": "^27.5.1",
|
||||
"@jest/reporters": "^27.5.1",
|
||||
"@jest/types": "^27",
|
||||
"@jest/console": "^29.3.1",
|
||||
"@jest/reporters": "^29.3.1",
|
||||
"@jest/types": "^29.3.1",
|
||||
"@kbn/ambient-storybook-types": "link:bazel-bin/packages/kbn-ambient-storybook-types",
|
||||
"@kbn/ambient-ui-types": "link:bazel-bin/packages/kbn-ambient-ui-types",
|
||||
"@kbn/apm-synthtrace": "link:bazel-bin/packages/kbn-apm-synthtrace",
|
||||
|
@ -801,7 +801,7 @@
|
|||
"@storybook/react-docgen-typescript-plugin": "^1.0.1",
|
||||
"@storybook/testing-react": "^1.3.0",
|
||||
"@storybook/theming": "^6.5.12",
|
||||
"@testing-library/dom": "^8.17.1",
|
||||
"@testing-library/dom": "^8.19.0",
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@testing-library/react": "^12.1.5",
|
||||
"@testing-library/react-hooks": "^8.0.1",
|
||||
|
@ -857,7 +857,7 @@
|
|||
"@types/http-proxy": "^1.17.4",
|
||||
"@types/inquirer": "^7.3.1",
|
||||
"@types/intl-relativeformat": "^2.1.0",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/jest": "29.2.0",
|
||||
"@types/jest-axe": "^3.5.3",
|
||||
"@types/jquery": "^3.3.31",
|
||||
"@types/js-levenshtein": "^1.1.0",
|
||||
|
@ -934,7 +934,7 @@
|
|||
"@types/tapable": "^1.0.6",
|
||||
"@types/tar": "^4.0.5",
|
||||
"@types/tempy": "^0.2.0",
|
||||
"@types/testing-library__jest-dom": "^5.14.3",
|
||||
"@types/testing-library__jest-dom": "^5.14.5",
|
||||
"@types/tinycolor2": "^1.4.1",
|
||||
"@types/tough-cookie": "^4.0.2",
|
||||
"@types/type-detect": "^4.0.1",
|
||||
|
@ -967,7 +967,7 @@
|
|||
"argsplit": "^1.0.5",
|
||||
"autoprefixer": "^10.4.7",
|
||||
"axe-core": "^4.0.2",
|
||||
"babel-jest": "^27.5.1",
|
||||
"babel-jest": "^29.2.2",
|
||||
"babel-loader": "^8.2.5",
|
||||
"babel-plugin-add-module-exports": "^1.0.4",
|
||||
"babel-plugin-istanbul": "^6.1.1",
|
||||
|
@ -1022,7 +1022,7 @@
|
|||
"eslint-plugin-react-perf": "^3.3.0",
|
||||
"eslint-traverse": "^1.0.0",
|
||||
"exit-hook": "^2.2.0",
|
||||
"expect": "^28.1.1",
|
||||
"expect": "^29.3.1",
|
||||
"expose-loader": "^0.7.5",
|
||||
"faker": "^5.1.0",
|
||||
"fetch-mock": "^7.3.9",
|
||||
|
@ -1040,19 +1040,18 @@
|
|||
"html-loader": "^1.3.2",
|
||||
"http-proxy": "^1.18.1",
|
||||
"is-path-inside": "^3.0.2",
|
||||
"jest": "^27.5.1",
|
||||
"jest": "^29.3.1",
|
||||
"jest-axe": "^5.0.0",
|
||||
"jest-canvas-mock": "^2.4.0",
|
||||
"jest-cli": "^27.5.1",
|
||||
"jest-config": "^27.5.1",
|
||||
"jest-diff": "^27.5.1",
|
||||
"jest-environment-jsdom": "^27.5.1",
|
||||
"jest-matcher-utils": "^27.5.1",
|
||||
"jest-mock": "^27.5.1",
|
||||
"jest-raw-loader": "^1.0.1",
|
||||
"jest-runtime": "^27.5.1",
|
||||
"jest-cli": "^29.3.1",
|
||||
"jest-config": "^29.3.1",
|
||||
"jest-diff": "^29.3.1",
|
||||
"jest-environment-jsdom": "^29.3.1",
|
||||
"jest-matcher-utils": "^29.3.1",
|
||||
"jest-mock": "^29.3.1",
|
||||
"jest-runtime": "^29.3.1",
|
||||
"jest-silent-reporter": "^0.5.0",
|
||||
"jest-snapshot": "^27.5.1",
|
||||
"jest-snapshot": "^29.3.1",
|
||||
"jest-specific-snapshot": "^5.0.0",
|
||||
"jest-styled-components": "7.0.3",
|
||||
"jsdom": "^16.4.0",
|
||||
|
@ -1092,7 +1091,6 @@
|
|||
"postcss-prefix-selector": "^1.16.0",
|
||||
"postcss-scss": "^4.0.4",
|
||||
"prettier": "^2.7.1",
|
||||
"pretty-format": "^27.5.1",
|
||||
"proxy": "^1.0.2",
|
||||
"q": "^1.5.1",
|
||||
"raw-loader": "^3.1.0",
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('AnalyticsClient', () => {
|
|||
let logger: MockedLogger;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
logger = loggerMock.create();
|
||||
analyticsClient = new AnalyticsClient({
|
||||
logger,
|
||||
|
|
|
@ -33,7 +33,7 @@ describe('ElasticV3BrowserShipper', () => {
|
|||
let fetchMock: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
fetchMock = jest.fn().mockResolvedValue({
|
||||
status: 200,
|
||||
|
|
|
@ -40,7 +40,7 @@ describe('ElasticV3ServerShipper', () => {
|
|||
const setLastBatchSent = (ms: number) => (shipper['lastBatchSent'] = ms);
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
shipper = new ElasticV3ServerShipper(
|
||||
{ version: '1.2.3', channelName: 'test-channel', debug: true },
|
||||
|
|
|
@ -54,7 +54,7 @@ const requiredProps: TableListViewProps = {
|
|||
// FLAKY: https://github.com/elastic/kibana/issues/145267
|
||||
describe.skip('TableListView', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -14,7 +14,7 @@ import { mocked } from './mocks_internal';
|
|||
|
||||
describe('EventLoopDelaysMonitor', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
const mockNow = jest.getRealSystemTime();
|
||||
jest.setSystemTime(mockNow);
|
||||
});
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('MetricsService', () => {
|
|||
let metricsService: MetricsService;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
const configService = configServiceMock.create({
|
||||
atPath: { interval: moment.duration(testInterval) },
|
||||
|
|
|
@ -56,7 +56,7 @@ describe('OverlayBannersService', () => {
|
|||
});
|
||||
|
||||
it('dismisses banner after timeout', async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
startService('testing banner!');
|
||||
expect(banners.remove).not.toHaveBeenCalled();
|
||||
|
||||
|
|
|
@ -551,7 +551,7 @@ test('`startPlugins` only starts plugins that were setup', async () => {
|
|||
|
||||
describe('setup', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
afterAll(() => {
|
||||
jest.useRealTimers();
|
||||
|
@ -588,7 +588,7 @@ describe('setup', () => {
|
|||
|
||||
describe('start', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
afterAll(() => {
|
||||
jest.useRealTimers();
|
||||
|
@ -747,7 +747,7 @@ describe('asynchronous plugins', () => {
|
|||
|
||||
describe('stop', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -61,7 +61,7 @@ const SHAREABLE_HIDDEN_OBJ_TYPE = 'type-c';
|
|||
const mockCurrentTime = new Date('2021-05-01T10:20:30Z');
|
||||
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(mockCurrentTime);
|
||||
});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Cache } from './cache';
|
|||
|
||||
describe('Cache', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -707,7 +707,7 @@ describe('ui settings', () => {
|
|||
describe('caching', () => {
|
||||
describe('read operations cache user config', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -15,7 +15,7 @@ import { extendedEnvSerializer } from './test_helpers';
|
|||
import { DevServer, Options } from './dev_server';
|
||||
import { TestLog } from './log';
|
||||
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
class MockProc extends EventEmitter {
|
||||
public readonly signalsSent: string[] = [];
|
||||
|
|
|
@ -61,7 +61,7 @@ describe('palette panel', () => {
|
|||
dataBounds: { min: 0, max: 100 },
|
||||
};
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
function changePaletteIn(instance: ReactWrapper, newPaletteName: string) {
|
||||
|
|
|
@ -90,7 +90,7 @@ describe('dateMath', function () {
|
|||
let now;
|
||||
|
||||
beforeEach(function () {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(unix);
|
||||
now = moment();
|
||||
mmnt = moment(anchor);
|
||||
|
@ -128,7 +128,7 @@ describe('dateMath', function () {
|
|||
let anchored;
|
||||
|
||||
beforeEach(function () {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(unix);
|
||||
now = moment();
|
||||
anchored = moment(anchor);
|
||||
|
@ -166,7 +166,7 @@ describe('dateMath', function () {
|
|||
let anchored;
|
||||
|
||||
beforeEach(function () {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(unix);
|
||||
now = moment();
|
||||
anchored = moment(anchor);
|
||||
|
@ -205,7 +205,7 @@ describe('dateMath', function () {
|
|||
let anchored;
|
||||
|
||||
beforeEach(function () {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(unix);
|
||||
now = moment();
|
||||
anchored = moment(anchor);
|
||||
|
@ -247,7 +247,7 @@ describe('dateMath', function () {
|
|||
let anchored;
|
||||
|
||||
beforeEach(function () {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(unix);
|
||||
now = moment();
|
||||
anchored = moment(anchor);
|
||||
|
|
|
@ -10,5 +10,4 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../..',
|
||||
roots: ['<rootDir>/packages/kbn-i18n-react'],
|
||||
testRunner: 'jasmine2',
|
||||
};
|
||||
|
|
|
@ -10,5 +10,4 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../..',
|
||||
roots: ['<rootDir>/packages/kbn-i18n'],
|
||||
testRunner: 'jasmine2',
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ describe('Painless DiagnosticAdapter', () => {
|
|||
let validation: LangValidation;
|
||||
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { fakeSchedulers } from 'rxjs-marbles/jest';
|
|||
|
||||
import { pipeClosure, debounceTimeBuffer, maybeMap, maybe } from './rxjs_helpers';
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
describe('pipeClosure()', () => {
|
||||
it('calls closure on each subscription to setup unique state', async () => {
|
||||
|
@ -70,7 +70,7 @@ describe('maybeMap()', () => {
|
|||
|
||||
describe('debounceTimeBuffer()', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -58,7 +58,7 @@ const bundleCacheEvent$ = Rx.from(BUNDLES).pipe(
|
|||
);
|
||||
|
||||
beforeEach(async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
|
|
@ -15,11 +15,12 @@ jest.mock('./focus_bundles');
|
|||
jest.mock('../limits');
|
||||
|
||||
jest.mock('os', () => {
|
||||
const realOs = jest.requireActual('os');
|
||||
jest.spyOn(realOs, 'cpus').mockImplementation(() => {
|
||||
return ['foo'] as any;
|
||||
});
|
||||
return realOs;
|
||||
return {
|
||||
...jest.requireActual('os'),
|
||||
cpus() {
|
||||
return ['foo'] as any;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
import Path from 'path';
|
||||
|
|
|
@ -93,6 +93,11 @@ module.exports = {
|
|||
'<rootDir>/node_modules/@kbn/test/target_node/src/jest/setup/react_testing_library.js',
|
||||
],
|
||||
|
||||
snapshotFormat: {
|
||||
escapeString: true,
|
||||
printBasicPrototype: true,
|
||||
},
|
||||
|
||||
// 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',
|
||||
|
@ -116,8 +121,8 @@ module.exports = {
|
|||
// A map from regular expressions to paths to transformers
|
||||
transform: {
|
||||
'^.+\\.(js|tsx?)$': '<rootDir>/node_modules/@kbn/test/target_node/src/jest/babel_transform.js',
|
||||
'^.+\\.txt?$': 'jest-raw-loader',
|
||||
'^.+\\.html?$': 'jest-raw-loader',
|
||||
'^.+\\.txt?$': '<rootDir>/node_modules/@kbn/test/target_node/src/jest/raw_transform.js',
|
||||
'^.+\\.html?$': '<rootDir>/node_modules/@kbn/test/target_node/src/jest/raw_transform.js',
|
||||
},
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
const preset = require('../jest-preset');
|
||||
|
||||
/** @typedef {import("@jest/types").Config.InitialOptions} JestConfig */
|
||||
/** @type {JestConfig} */
|
||||
module.exports = {
|
||||
...preset,
|
||||
testMatch: ['**/integration_tests**/*.test.{js,mjs,ts,tsx}'],
|
||||
|
|
|
@ -12,6 +12,8 @@ const presetClone = { ...preset };
|
|||
|
||||
delete presetClone.testEnvironment; // simply redefining as `testEnvironment: 'node'` has some weird side-effects (https://github.com/elastic/kibana/pull/138877#issuecomment-1222366247)
|
||||
|
||||
/** @typedef {import("@jest/types").Config.InitialOptions} JestConfig */
|
||||
/** @type {JestConfig} */
|
||||
module.exports = {
|
||||
...presetClone,
|
||||
snapshotSerializers: [],
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
} from 'jest-snapshot';
|
||||
import path from 'path';
|
||||
import { once } from 'lodash';
|
||||
import type { SyncExpectationResult } from 'expect';
|
||||
import { Lifecycle } from '../lifecycle';
|
||||
import { Suite, Test } from '../../fake_mocha_types';
|
||||
|
||||
|
@ -154,13 +155,14 @@ export function decorateSnapshotUi({
|
|||
function getSnapshotState(file: string, updateSnapshot: SnapshotUpdateState) {
|
||||
const dirname = path.dirname(file);
|
||||
const filename = path.basename(file);
|
||||
|
||||
const rootDir = path.join(dirname + `/__snapshots__/`);
|
||||
const snapshotState = new SnapshotState(
|
||||
path.join(dirname + `/__snapshots__/` + filename.replace(path.extname(filename), '.snap')),
|
||||
path.join(rootDir, filename.replace(path.extname(filename), '.snap')),
|
||||
{
|
||||
updateSnapshot,
|
||||
prettierPath: require.resolve('prettier'),
|
||||
snapshotFormat: { escapeString: true, printBasicPrototype: true },
|
||||
rootDir,
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -203,7 +205,7 @@ export function expectSnapshot(received: any) {
|
|||
|
||||
function expectToMatchSnapshot(snapshotContext: SnapshotContext, received: any) {
|
||||
const matcher = toMatchSnapshot.bind(snapshotContext as any);
|
||||
const result = matcher(received);
|
||||
const result = matcher(received) as SyncExpectationResult;
|
||||
|
||||
if (!result.pass) {
|
||||
throw new Error(result.message());
|
||||
|
@ -217,7 +219,9 @@ function expectToMatchInlineSnapshot(
|
|||
) {
|
||||
const matcher = toMatchInlineSnapshot.bind(snapshotContext as any);
|
||||
|
||||
const result = arguments.length === 2 ? matcher(received) : matcher(received, _actual);
|
||||
const result = (
|
||||
arguments.length === 2 ? matcher(received) : matcher(received, _actual)
|
||||
) as SyncExpectationResult;
|
||||
|
||||
if (!result.pass) {
|
||||
throw new Error(result.message());
|
||||
|
|
15
packages/kbn-test/src/jest/raw_transform.js
Normal file
15
packages/kbn-test/src/jest/raw_transform.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
process(sourceText) {
|
||||
return {
|
||||
code: `module.exports = ${JSON.stringify(sourceText)}`,
|
||||
};
|
||||
},
|
||||
};
|
|
@ -9,7 +9,7 @@
|
|||
import { TimedItemBuffer } from '../timed_item_buffer';
|
||||
import { runItemBufferTests } from './run_item_buffer_tests';
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllTimers();
|
||||
|
|
|
@ -51,7 +51,7 @@ const setup = () => {
|
|||
|
||||
describe('createStreamingBatchedFunction()', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/console'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/console',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/console/{common,public,server}/**/*.{js,ts,tsx}'],
|
||||
|
|
|
@ -47,7 +47,7 @@ describe('Output Tokenization', () => {
|
|||
data = JSON.stringify(data, null, 3);
|
||||
}
|
||||
|
||||
test('Token test ' + testCount++, async function (done) {
|
||||
test('Token test ' + testCount++, function (done) {
|
||||
output.update(data, function () {
|
||||
const tokens = tokensAsList();
|
||||
const normTokenList = [];
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('Integration', () => {
|
|||
});
|
||||
|
||||
function processContextTest(data, mapping, kbSchemes, requestLine, testToRun) {
|
||||
test(testToRun.name, async function (done) {
|
||||
test(testToRun.name, function (done) {
|
||||
let lineOffset = 0; // add one for the extra method line
|
||||
let editorValue = data;
|
||||
if (requestLine != null) {
|
||||
|
@ -70,103 +70,103 @@ describe('Integration', () => {
|
|||
}
|
||||
kb.setActiveApi(testApi);
|
||||
const { cursor } = testToRun;
|
||||
await senseEditor.update(editorValue, true);
|
||||
senseEditor.getCoreEditor().moveCursorToPosition(cursor);
|
||||
senseEditor.update(editorValue, true).then(() => {
|
||||
senseEditor.getCoreEditor().moveCursorToPosition(cursor);
|
||||
// allow ace rendering to move cursor so it will be seen during test - handy for debugging.
|
||||
//setTimeout(function () {
|
||||
senseEditor.completer = {
|
||||
base: {},
|
||||
changeListener: function () {},
|
||||
}; // mimic auto complete
|
||||
|
||||
// allow ace rendering to move cursor so it will be seen during test - handy for debugging.
|
||||
//setTimeout(function () {
|
||||
senseEditor.completer = {
|
||||
base: {},
|
||||
changeListener: function () {},
|
||||
}; // mimic auto complete
|
||||
senseEditor.autocomplete._test.getCompletions(
|
||||
senseEditor,
|
||||
null,
|
||||
cursor,
|
||||
'',
|
||||
function (err, terms) {
|
||||
if (testToRun.assertThrows) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
senseEditor.autocomplete._test.getCompletions(
|
||||
senseEditor,
|
||||
null,
|
||||
cursor,
|
||||
'',
|
||||
function (err, terms) {
|
||||
if (testToRun.assertThrows) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (testToRun.no_context) {
|
||||
expect(!terms || terms.length === 0).toBeTruthy();
|
||||
} else {
|
||||
expect(terms).not.toBeNull();
|
||||
expect(terms.length).toBeGreaterThan(0);
|
||||
}
|
||||
|
||||
if (!terms || terms.length === 0) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
if (testToRun.autoCompleteSet) {
|
||||
const expectedTerms = _.map(testToRun.autoCompleteSet, function (t) {
|
||||
if (typeof t !== 'object') {
|
||||
t = { name: t };
|
||||
}
|
||||
return t;
|
||||
});
|
||||
if (terms.length !== expectedTerms.length) {
|
||||
expect(_.map(terms, 'name')).toEqual(_.map(expectedTerms, 'name'));
|
||||
if (testToRun.no_context) {
|
||||
expect(!terms || terms.length === 0).toBeTruthy();
|
||||
} else {
|
||||
const filteredActualTerms = _.map(terms, function (actualTerm, i) {
|
||||
const expectedTerm = expectedTerms[i];
|
||||
const filteredTerm = {};
|
||||
_.each(expectedTerm, function (v, p) {
|
||||
filteredTerm[p] = actualTerm[p];
|
||||
});
|
||||
return filteredTerm;
|
||||
});
|
||||
expect(filteredActualTerms).toEqual(expectedTerms);
|
||||
expect(terms).not.toBeNull();
|
||||
expect(terms.length).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
const context = terms[0].context;
|
||||
const {
|
||||
cursor: { lineNumber, column },
|
||||
} = testToRun;
|
||||
senseEditor.autocomplete._test.addReplacementInfoToContext(
|
||||
context,
|
||||
{ lineNumber, column },
|
||||
terms[0].value
|
||||
);
|
||||
if (!terms || terms.length === 0) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
function ac(prop, propTest) {
|
||||
if (typeof testToRun[prop] !== 'undefined') {
|
||||
if (propTest) {
|
||||
propTest(context[prop], testToRun[prop], prop);
|
||||
if (testToRun.autoCompleteSet) {
|
||||
const expectedTerms = _.map(testToRun.autoCompleteSet, function (t) {
|
||||
if (typeof t !== 'object') {
|
||||
t = { name: t };
|
||||
}
|
||||
return t;
|
||||
});
|
||||
if (terms.length !== expectedTerms.length) {
|
||||
expect(_.map(terms, 'name')).toEqual(_.map(expectedTerms, 'name'));
|
||||
} else {
|
||||
expect(context[prop]).toEqual(testToRun[prop]);
|
||||
const filteredActualTerms = _.map(terms, function (actualTerm, i) {
|
||||
const expectedTerm = expectedTerms[i];
|
||||
const filteredTerm = {};
|
||||
_.each(expectedTerm, function (v, p) {
|
||||
filteredTerm[p] = actualTerm[p];
|
||||
});
|
||||
return filteredTerm;
|
||||
});
|
||||
expect(filteredActualTerms).toEqual(expectedTerms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function posCompare(actual, expected) {
|
||||
expect(actual.lineNumber).toEqual(expected.lineNumber + lineOffset);
|
||||
expect(actual.column).toEqual(expected.column);
|
||||
}
|
||||
const context = terms[0].context;
|
||||
const {
|
||||
cursor: { lineNumber, column },
|
||||
} = testToRun;
|
||||
senseEditor.autocomplete._test.addReplacementInfoToContext(
|
||||
context,
|
||||
{ lineNumber, column },
|
||||
terms[0].value
|
||||
);
|
||||
|
||||
function rangeCompare(actual, expected, name) {
|
||||
posCompare(actual.start, expected.start, name + '.start');
|
||||
posCompare(actual.end, expected.end, name + '.end');
|
||||
}
|
||||
function ac(prop, propTest) {
|
||||
if (typeof testToRun[prop] !== 'undefined') {
|
||||
if (propTest) {
|
||||
propTest(context[prop], testToRun[prop], prop);
|
||||
} else {
|
||||
expect(context[prop]).toEqual(testToRun[prop]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ac('prefixToAdd');
|
||||
ac('suffixToAdd');
|
||||
ac('addTemplate');
|
||||
ac('textBoxPosition', posCompare);
|
||||
ac('rangeToReplace', rangeCompare);
|
||||
done();
|
||||
}
|
||||
);
|
||||
function posCompare(actual, expected) {
|
||||
expect(actual.lineNumber).toEqual(expected.lineNumber + lineOffset);
|
||||
expect(actual.column).toEqual(expected.column);
|
||||
}
|
||||
|
||||
function rangeCompare(actual, expected, name) {
|
||||
posCompare(actual.start, expected.start, name + '.start');
|
||||
posCompare(actual.end, expected.end, name + '.end');
|
||||
}
|
||||
|
||||
ac('prefixToAdd');
|
||||
ac('suffixToAdd');
|
||||
ac('addTemplate');
|
||||
ac('textBoxPosition', posCompare);
|
||||
ac('rangeToReplace', rangeCompare);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -83,9 +83,10 @@ describe('Editor', () => {
|
|||
data = prefix;
|
||||
}
|
||||
|
||||
test('Utils test ' + id + ' : ' + name, async function (done) {
|
||||
await input.update(data, true);
|
||||
testToRun(done);
|
||||
test('Utils test ' + id + ' : ' + name, function (done) {
|
||||
input.update(data, true).then(() => {
|
||||
testToRun(done);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/controls'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/controls',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/controls/{common,public,server}/**/*.{ts,tsx}'],
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/custom_integrations'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/custom_integrations',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/data/{common,public,server}/**/*.{ts,tsx}'],
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/dashboard'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/dashboard',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/dashboard/{common,public,server}/**/*.{ts,tsx}'],
|
||||
|
|
|
@ -73,9 +73,9 @@ describe('DatatableUtilitiesService', () => {
|
|||
it('should return a data view field instance', async () => {
|
||||
const column = { meta: { field: 'field', index: 'index' } } as DatatableColumn;
|
||||
const dataView = createStubDataView({ spec: {} });
|
||||
const field = {};
|
||||
spyOn(datatableUtilitiesService, 'getDataView').and.returnValue(dataView);
|
||||
spyOn(dataView, 'getFieldByName').and.returnValue(field);
|
||||
const field = {} as any;
|
||||
jest.spyOn(datatableUtilitiesService, 'getDataView').mockResolvedValue(dataView);
|
||||
jest.spyOn(dataView, 'getFieldByName').mockReturnValue(field);
|
||||
|
||||
await expect(datatableUtilitiesService.getField(column)).resolves.toBe(field);
|
||||
expect(dataView.getFieldByName).toHaveBeenCalledWith('field');
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/data'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/data',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/data/{common,public,server}/**/*.{ts,tsx}'],
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { createAutoRefreshLoop, AutoRefreshDoneFn } from './auto_refresh_loop';
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
test('triggers refresh with interval', () => {
|
||||
const { loop$, start, stop } = createAutoRefreshLoop();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
import sinon from 'sinon';
|
||||
import moment from 'moment';
|
||||
|
|
|
@ -50,7 +50,7 @@ const sessionId = 'abcd';
|
|||
|
||||
describe('Filtering and showing warnings', () => {
|
||||
const notifications = notificationServiceMock.createStartContract();
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
describe('handleWarnings', () => {
|
||||
const request = { body: {} };
|
||||
|
|
|
@ -75,7 +75,7 @@ describe('search abort controller', () => {
|
|||
|
||||
describe('timeout abort', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -44,7 +44,7 @@ let fetchMock: jest.Mock<any>;
|
|||
const flushPromises = () =>
|
||||
new Promise((resolve) => jest.requireActual('timers').setImmediate(resolve));
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
const timeTravel = async (msToRun = 0) => {
|
||||
await flushPromises();
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('Search service', () => {
|
|||
let mockCoreSetup: MockedKeys<CoreSetup>;
|
||||
let mockCoreStart: MockedKeys<CoreStart>;
|
||||
const initializerContext = coreMock.createPluginInitializerContext();
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
initializerContext.config.get = jest.fn().mockReturnValue({
|
||||
search: { aggs: { shardDelay: { enabled: false } }, sessions: { enabled: true } },
|
||||
});
|
||||
|
|
|
@ -65,7 +65,7 @@ beforeEach(() => {
|
|||
|
||||
describe('waitUntilNextSessionCompletes$', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
|
|
|
@ -226,7 +226,7 @@ describe('Completed inactivity', () => {
|
|||
describe('tour steps', () => {
|
||||
describe('loading state', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -152,7 +152,7 @@ describe('Background Search Session Management Table', () => {
|
|||
// FLAKY: https://github.com/elastic/kibana/issues/88928
|
||||
describe.skip('fetching sessions data', () => {
|
||||
test('re-fetches data', async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
sessionsClient.find = jest.fn();
|
||||
mockConfig = {
|
||||
...mockConfig,
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Subject } from 'rxjs';
|
|||
import { getRequestAbortedSignal } from './get_request_aborted_signal';
|
||||
|
||||
describe('abortableRequestHandler', () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
it('should call abort if disconnected', () => {
|
||||
const abortedSubject = new Subject<void>();
|
||||
|
|
|
@ -65,7 +65,7 @@ describe('<FieldEditor />', () => {
|
|||
};
|
||||
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('<FieldEditorFlyoutContent />', () => {
|
|||
const { httpRequestsMockHelpers } = setupEnvironment();
|
||||
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('Field editor Preview panel', () => {
|
|||
const { server, httpRequestsMockHelpers } = setupEnvironment();
|
||||
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/data_view_management'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/data_view_management',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/data_view_management/{public,server}/**/*.{ts,tsx}'],
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/discover'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/discover',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/discover/{common,public,server}/**/*.{js,ts,tsx}'],
|
||||
|
|
|
@ -75,7 +75,7 @@ describe('getFetchObservable', () => {
|
|||
test(
|
||||
'getAutoRefreshFetch$ should trigger fetch$.next',
|
||||
fakeSchedulers((advance) => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
const searchSessionManagerMock = createSearchSessionMock();
|
||||
const autoRefreshFetch$ = new Subject();
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/embeddable'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/embeddable',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/embeddable/{common,public,server}/**/*.{ts,tsx}'],
|
||||
|
|
|
@ -211,10 +211,7 @@ describe('createStore', () => {
|
|||
await new Promise((resolve) => setTimeout(resolve));
|
||||
|
||||
expect(store.getState()).toHaveProperty('input.custom', 'something else');
|
||||
expect(container.getInput()).toHaveProperty(
|
||||
'input.custom',
|
||||
expect.not.stringMatching('something else')
|
||||
);
|
||||
expect(container.getInput()).not.toHaveProperty('input.custom');
|
||||
});
|
||||
|
||||
it('should restore value from the inherited input', async () => {
|
||||
|
|
|
@ -49,7 +49,7 @@ const errorWithBodyResponse = { body: errorValue };
|
|||
export const createUseRequestHelpers = (): UseRequestHelpers => {
|
||||
// The behavior we're testing involves state changes over time, so we need finer control over
|
||||
// timing.
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
const flushPromiseJobQueue = async () => {
|
||||
// See https://stackoverflow.com/questions/52177631/jest-timer-and-promise-dont-work-well-settimeout-and-async-function
|
||||
|
|
|
@ -18,7 +18,7 @@ import { UseArray } from './use_array';
|
|||
|
||||
describe('<UseArray />', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -19,7 +19,7 @@ import { UseField } from './use_field';
|
|||
|
||||
describe('<UseField />', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -15,7 +15,7 @@ import { UseMultiFields } from './use_multi_fields';
|
|||
|
||||
describe('<UseMultiFields />', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -17,7 +17,7 @@ import { FieldHook, FieldValidateResponse, VALIDATION_TYPES, FieldConfig } from
|
|||
|
||||
describe('useField() hook', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -40,7 +40,7 @@ const onFormHook = (_form: FormHook<any>) => {
|
|||
|
||||
describe('useForm() hook', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -13,7 +13,7 @@ import { parseExpression } from '../ast';
|
|||
import { createUnitTestExecutor } from '../test_helpers';
|
||||
import { ExpressionFunctionDefinition } from '../expression_functions';
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllTimers();
|
||||
|
@ -82,7 +82,7 @@ describe('Execution abortion tests', () => {
|
|||
|
||||
expect(result).toBe(null);
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
test('nested expressions are aborted when parent aborted', async () => {
|
||||
|
@ -151,6 +151,6 @@ describe('Execution abortion tests', () => {
|
|||
expect(aborted).toHaveBeenCalledTimes(1);
|
||||
expect(completed).toHaveBeenCalledTimes(0);
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -387,7 +387,7 @@ describe('Execution', () => {
|
|||
});
|
||||
|
||||
test('result is undefined until execution completes', async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
const execution = createExecution('sleep 10');
|
||||
expect(execution.state.get().result).toBe(undefined);
|
||||
execution.start(null).subscribe(jest.fn());
|
||||
|
@ -623,7 +623,7 @@ describe('Execution', () => {
|
|||
});
|
||||
|
||||
test('execution state is "pending" while execution is in progress', async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
const execution = createExecution('sleep 20');
|
||||
execution.start(null);
|
||||
jest.advanceTimersByTime(5);
|
||||
|
|
|
@ -76,13 +76,11 @@ jest.mock('./services', () => {
|
|||
|
||||
const execute = service.execute;
|
||||
|
||||
jest.spyOn(service, 'execute').mockImplementation((...args) => {
|
||||
// @ts-expect-error
|
||||
service.execute = (...args: Parameters<ExpressionsService['execute']>) => {
|
||||
execution = execute(...args);
|
||||
jest.spyOn(execution, 'getData');
|
||||
jest.spyOn(execution, 'cancel');
|
||||
|
||||
return execution;
|
||||
});
|
||||
};
|
||||
|
||||
return moduleMock;
|
||||
});
|
||||
|
|
|
@ -103,7 +103,7 @@ describe('ExpressionRenderer', () => {
|
|||
});
|
||||
|
||||
it('waits for debounce period if specified', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
const refreshSubject = new Subject();
|
||||
const loaderUpdate = jest.fn();
|
||||
|
@ -136,7 +136,7 @@ describe('ExpressionRenderer', () => {
|
|||
});
|
||||
|
||||
it('should not update twice immediately after rendering', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
const refreshSubject = new Subject();
|
||||
const loaderUpdate = jest.fn();
|
||||
|
@ -165,7 +165,7 @@ describe('ExpressionRenderer', () => {
|
|||
});
|
||||
|
||||
it('waits for debounce period on other loader option change if specified', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
const refreshSubject = new Subject();
|
||||
const loaderUpdate = jest.fn();
|
||||
|
|
|
@ -11,7 +11,7 @@ import { useDebouncedValue } from './use_debounced_value';
|
|||
|
||||
describe('useDebouncedValue', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -64,7 +64,7 @@ describe('useExpressionRenderer', () => {
|
|||
});
|
||||
|
||||
it('should debounce property changes', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
hook.rerender({ debounce: 1000, expression: 'something else' });
|
||||
expect(expressionLoader.update).not.toHaveBeenCalled();
|
||||
|
@ -79,7 +79,7 @@ describe('useExpressionRenderer', () => {
|
|||
});
|
||||
|
||||
it('should not debounce if loader optaions are not changed', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
hook.rerender({ expression: 'something else', partial: true });
|
||||
hook.rerender({
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/guided_onboarding'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/guided_onboarding',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: [
|
||||
|
|
|
@ -255,6 +255,7 @@ describe('GuidedOnboarding ApiService', () => {
|
|||
.isGuideStepActive$(testGuide, testGuideFirstStep)
|
||||
.subscribe((isStepActive) => {
|
||||
if (isStepActive) {
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
@ -265,6 +266,7 @@ describe('GuidedOnboarding ApiService', () => {
|
|||
.isGuideStepActive$(testGuide, testGuideFirstStep)
|
||||
.subscribe((isStepActive) => {
|
||||
if (!isStepActive) {
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
@ -408,6 +410,7 @@ describe('GuidedOnboarding ApiService', () => {
|
|||
.isGuidedOnboardingActiveForIntegration$(testIntegration)
|
||||
.subscribe((isIntegrationInGuideStep) => {
|
||||
if (isIntegrationInGuideStep) {
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
@ -422,6 +425,7 @@ describe('GuidedOnboarding ApiService', () => {
|
|||
.isGuidedOnboardingActiveForIntegration$(wrongIntegration)
|
||||
.subscribe((isIntegrationInGuideStep) => {
|
||||
if (!isIntegrationInGuideStep) {
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
@ -436,6 +440,7 @@ describe('GuidedOnboarding ApiService', () => {
|
|||
.isGuidedOnboardingActiveForIntegration$(testIntegration)
|
||||
.subscribe((isIntegrationInGuideStep) => {
|
||||
if (!isIntegrationInGuideStep) {
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -86,7 +86,7 @@ describe('ElasticsearchService', () => {
|
|||
});
|
||||
|
||||
describe('#connectionStatus$', () => {
|
||||
beforeEach(() => jest.useFakeTimers('legacy'));
|
||||
beforeEach(() => jest.useFakeTimers({ legacyFakeTimers: true }));
|
||||
afterEach(() => jest.useRealTimers());
|
||||
|
||||
it('does not repeat ping request if have multiple subscriptions', async () => {
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('serializeSavedObjectId', () => {
|
|||
describe('storeHistogram', () => {
|
||||
const eventLoopDelaysMonitor = metricsServiceMock.createEventLoopDelaysMonitor();
|
||||
const mockInternalRepository = savedObjectsRepositoryMock.create();
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
const mockNow = jest.getRealSystemTime();
|
||||
jest.setSystemTime(mockNow);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ describe('startTrackingEventLoopDelaysUsage', () => {
|
|||
const stopMonitoringEventLoop$ = new Subject<void>();
|
||||
const instanceUuid = 'mock_uuid';
|
||||
|
||||
beforeAll(() => jest.useFakeTimers('modern'));
|
||||
beforeAll(() => jest.useFakeTimers());
|
||||
beforeEach(() => jest.clearAllMocks());
|
||||
afterEach(() => stopMonitoringEventLoop$.next());
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('startTrackingEventLoopDelaysThreshold', () => {
|
|||
const mockEventLoopCounter = mockUsageCountersSetup.createUsageCounter('testCounter');
|
||||
const eventLoopDelaysMonitor = metricsServiceMock.createEventLoopDelaysMonitor();
|
||||
|
||||
beforeAll(() => jest.useFakeTimers('modern'));
|
||||
beforeAll(() => jest.useFakeTimers());
|
||||
beforeEach(() => jest.clearAllMocks());
|
||||
afterEach(() => stopMonitoringEventLoop$.next());
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { AbortError, abortSignalToPromise } from './abort_utils';
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
const flushPromises = () =>
|
||||
new Promise((resolve) => jest.requireActual('timers').setImmediate(resolve));
|
||||
|
|
|
@ -109,7 +109,7 @@ describe('hashedItemStore', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
// Control time.
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
sessionStorage = new StubBrowserStorage();
|
||||
hashedItemStore = new HashedItemStore(sessionStorage);
|
||||
|
@ -199,7 +199,7 @@ describe('hashedItemStore', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
// Control time.
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
sessionStorage = new StubBrowserStorage();
|
||||
hashedItemStore = new HashedItemStore(sessionStorage);
|
||||
|
@ -350,7 +350,7 @@ describe('hashedItemStore', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
// Control time.
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
sessionStorage = new StubBrowserStorage();
|
||||
hashedItemStore = new HashedItemStore(sessionStorage);
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ describe('Newsfeed plugin', () => {
|
|||
let plugin: NewsfeedPublicPlugin;
|
||||
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/saved_search'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/saved_search',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: [
|
||||
|
|
|
@ -246,7 +246,7 @@ describe('TelemetrySender', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
window.fetch = mockFetch = jest.fn();
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
consoleWarnMock = jest.spyOn(global.console, 'warn').mockImplementation(() => {});
|
||||
});
|
||||
|
||||
|
@ -380,7 +380,7 @@ describe('TelemetrySender', () => {
|
|||
});
|
||||
|
||||
describe('getRetryDelay', () => {
|
||||
beforeEach(() => jest.useFakeTimers('legacy'));
|
||||
beforeEach(() => jest.useFakeTimers({ legacyFakeTimers: true }));
|
||||
afterAll(() => jest.useRealTimers());
|
||||
|
||||
it('sets a minimum retry delay of 60 seconds', () => {
|
||||
|
@ -399,7 +399,7 @@ describe('TelemetrySender', () => {
|
|||
});
|
||||
|
||||
describe('startChecking', () => {
|
||||
beforeEach(() => jest.useFakeTimers('legacy'));
|
||||
beforeEach(() => jest.useFakeTimers({ legacyFakeTimers: true }));
|
||||
afterAll(() => jest.useRealTimers());
|
||||
|
||||
it('calls sendIfDue every 60000 ms', () => {
|
||||
|
|
|
@ -28,7 +28,7 @@ import { fetchMock, getNextAttemptDateMock } from './fetcher.test.mock';
|
|||
import { FetcherTask } from './fetcher';
|
||||
|
||||
describe('FetcherTask', () => {
|
||||
beforeEach(() => jest.useFakeTimers('legacy'));
|
||||
beforeEach(() => jest.useFakeTimers({ legacyFakeTimers: true }));
|
||||
|
||||
describe('sendIfDue', () => {
|
||||
let getCurrentConfigs: jest.Mock;
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('CacheManager', () => {
|
|||
let mockNow: number;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
mockNow = jest.getRealSystemTime();
|
||||
jest.setSystemTime(mockNow);
|
||||
});
|
||||
|
|
|
@ -44,7 +44,7 @@ const reset = () => {
|
|||
|
||||
executeFn.mockReset();
|
||||
openContextMenuSpy.mockReset();
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
};
|
||||
beforeEach(reset);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import { QueryLanguageSwitcher } from './language_switcher';
|
|||
import QueryStringInput from './query_string_input';
|
||||
import { unifiedSearchPluginMock } from '../mocks';
|
||||
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
const startMock = coreMock.createStart();
|
||||
|
||||
const noop = () => {
|
||||
|
|
|
@ -1,107 +1,111 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`CollectorSet bulkFetch skips collectors that are not ready 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"result": Object {},
|
||||
"type": "ready_col",
|
||||
},
|
||||
Object {
|
||||
"result": Object {
|
||||
"failed": Object {
|
||||
"count": 0,
|
||||
"names": Array [],
|
||||
},
|
||||
"fetch_duration_breakdown": Array [
|
||||
Object {
|
||||
"duration": 0,
|
||||
"name": "ready_col",
|
||||
},
|
||||
],
|
||||
"is_ready_duration_breakdown": Array [
|
||||
Object {
|
||||
"duration": 0,
|
||||
"name": "ready_col",
|
||||
},
|
||||
Object {
|
||||
"duration": 0,
|
||||
"name": "not_ready_col",
|
||||
},
|
||||
],
|
||||
"not_ready": Object {
|
||||
"count": 1,
|
||||
"names": Array [
|
||||
"not_ready_col",
|
||||
],
|
||||
},
|
||||
"not_ready_timeout": Object {
|
||||
"count": 0,
|
||||
"names": Array [],
|
||||
},
|
||||
"succeeded": Object {
|
||||
"count": 1,
|
||||
"names": Array [
|
||||
"ready_col",
|
||||
],
|
||||
},
|
||||
"total_duration": 0,
|
||||
"total_fetch_duration": 0,
|
||||
"total_is_ready_duration": 0,
|
||||
Object {
|
||||
"results": Array [
|
||||
Object {
|
||||
"result": Object {},
|
||||
"type": "ready_col",
|
||||
},
|
||||
"type": "usage_collector_stats",
|
||||
},
|
||||
]
|
||||
Object {
|
||||
"result": Object {
|
||||
"failed": Object {
|
||||
"count": 0,
|
||||
"names": Array [],
|
||||
},
|
||||
"fetch_duration_breakdown": Array [
|
||||
Object {
|
||||
"duration": 0,
|
||||
"name": "ready_col",
|
||||
},
|
||||
],
|
||||
"is_ready_duration_breakdown": Array [
|
||||
Object {
|
||||
"duration": 0,
|
||||
"name": "ready_col",
|
||||
},
|
||||
Object {
|
||||
"duration": 0,
|
||||
"name": "not_ready_col",
|
||||
},
|
||||
],
|
||||
"not_ready": Object {
|
||||
"count": 1,
|
||||
"names": Array [
|
||||
"not_ready_col",
|
||||
],
|
||||
},
|
||||
"not_ready_timeout": Object {
|
||||
"count": 0,
|
||||
"names": Array [],
|
||||
},
|
||||
"succeeded": Object {
|
||||
"count": 1,
|
||||
"names": Array [
|
||||
"ready_col",
|
||||
],
|
||||
},
|
||||
"total_duration": 0,
|
||||
"total_fetch_duration": 0,
|
||||
"total_is_ready_duration": 0,
|
||||
},
|
||||
"type": "usage_collector_stats",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`CollectorSet bulkFetch skips collectors that have timed out 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"result": Object {},
|
||||
"type": "ready_col",
|
||||
},
|
||||
Object {
|
||||
"result": Object {
|
||||
"failed": Object {
|
||||
"count": 0,
|
||||
"names": Array [],
|
||||
},
|
||||
"fetch_duration_breakdown": Array [
|
||||
Object {
|
||||
"duration": 0,
|
||||
"name": "ready_col",
|
||||
},
|
||||
],
|
||||
"is_ready_duration_breakdown": Array [
|
||||
Object {
|
||||
"duration": Any<Number>,
|
||||
"name": "ready_col",
|
||||
},
|
||||
Object {
|
||||
"duration": Any<Number>,
|
||||
"name": "timeout_col",
|
||||
},
|
||||
],
|
||||
"not_ready": Object {
|
||||
"count": 0,
|
||||
"names": Array [],
|
||||
},
|
||||
"not_ready_timeout": Object {
|
||||
"count": 1,
|
||||
"names": Array [
|
||||
"timeout_col",
|
||||
],
|
||||
},
|
||||
"succeeded": Object {
|
||||
"count": 1,
|
||||
"names": Array [
|
||||
"ready_col",
|
||||
],
|
||||
},
|
||||
"total_duration": Any<Number>,
|
||||
"total_fetch_duration": 0,
|
||||
"total_is_ready_duration": Any<Number>,
|
||||
Object {
|
||||
"results": Array [
|
||||
Object {
|
||||
"result": Object {},
|
||||
"type": "ready_col",
|
||||
},
|
||||
"type": "usage_collector_stats",
|
||||
},
|
||||
]
|
||||
Object {
|
||||
"result": Object {
|
||||
"failed": Object {
|
||||
"count": 0,
|
||||
"names": Array [],
|
||||
},
|
||||
"fetch_duration_breakdown": Array [
|
||||
Object {
|
||||
"duration": 0,
|
||||
"name": "ready_col",
|
||||
},
|
||||
],
|
||||
"is_ready_duration_breakdown": Array [
|
||||
Object {
|
||||
"duration": Any<Number>,
|
||||
"name": "ready_col",
|
||||
},
|
||||
Object {
|
||||
"duration": Any<Number>,
|
||||
"name": "timeout_col",
|
||||
},
|
||||
],
|
||||
"not_ready": Object {
|
||||
"count": 0,
|
||||
"names": Array [],
|
||||
},
|
||||
"not_ready_timeout": Object {
|
||||
"count": 1,
|
||||
"names": Array [
|
||||
"timeout_col",
|
||||
],
|
||||
},
|
||||
"succeeded": Object {
|
||||
"count": 1,
|
||||
"names": Array [
|
||||
"ready_col",
|
||||
],
|
||||
},
|
||||
"total_duration": Any<Number>,
|
||||
"total_fetch_duration": 0,
|
||||
"total_is_ready_duration": Any<Number>,
|
||||
},
|
||||
"type": "usage_collector_stats",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -374,52 +374,55 @@ describe('CollectorSet', () => {
|
|||
expect(mockIsNotReady).toBeCalledTimes(1);
|
||||
expect(mockNonReadyFetch).toBeCalledTimes(0);
|
||||
|
||||
expect(results).toMatchSnapshot([
|
||||
{
|
||||
result: {},
|
||||
type: 'ready_col',
|
||||
},
|
||||
{
|
||||
result: {
|
||||
failed: {
|
||||
count: 0,
|
||||
names: [],
|
||||
},
|
||||
fetch_duration_breakdown: [
|
||||
{
|
||||
name: 'ready_col',
|
||||
duration: 0,
|
||||
},
|
||||
],
|
||||
is_ready_duration_breakdown: [
|
||||
{
|
||||
name: 'ready_col',
|
||||
duration: 0,
|
||||
},
|
||||
{
|
||||
name: 'not_ready_col',
|
||||
duration: 0,
|
||||
},
|
||||
],
|
||||
not_ready: {
|
||||
count: 1,
|
||||
names: ['not_ready_col'],
|
||||
},
|
||||
not_ready_timeout: {
|
||||
count: 0,
|
||||
names: [],
|
||||
},
|
||||
succeeded: {
|
||||
count: 1,
|
||||
names: ['ready_col'],
|
||||
},
|
||||
total_duration: 0,
|
||||
total_fetch_duration: 0,
|
||||
total_is_ready_duration: 0,
|
||||
// Passing object instead of array due to https://github.com/facebook/jest/issues/13352
|
||||
expect({ results }).toMatchSnapshot({
|
||||
results: [
|
||||
{
|
||||
result: {},
|
||||
type: 'ready_col',
|
||||
},
|
||||
type: 'usage_collector_stats',
|
||||
},
|
||||
]);
|
||||
{
|
||||
result: {
|
||||
failed: {
|
||||
count: 0,
|
||||
names: [],
|
||||
},
|
||||
fetch_duration_breakdown: [
|
||||
{
|
||||
name: 'ready_col',
|
||||
duration: 0,
|
||||
},
|
||||
],
|
||||
is_ready_duration_breakdown: [
|
||||
{
|
||||
name: 'ready_col',
|
||||
duration: 0,
|
||||
},
|
||||
{
|
||||
name: 'not_ready_col',
|
||||
duration: 0,
|
||||
},
|
||||
],
|
||||
not_ready: {
|
||||
count: 1,
|
||||
names: ['not_ready_col'],
|
||||
},
|
||||
not_ready_timeout: {
|
||||
count: 0,
|
||||
names: [],
|
||||
},
|
||||
succeeded: {
|
||||
count: 1,
|
||||
names: ['ready_col'],
|
||||
},
|
||||
total_duration: 0,
|
||||
total_fetch_duration: 0,
|
||||
total_is_ready_duration: 0,
|
||||
},
|
||||
type: 'usage_collector_stats',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('skips collectors that have timed out', async () => {
|
||||
|
@ -461,52 +464,55 @@ describe('CollectorSet', () => {
|
|||
expect(mockTimedOutReady).toBeCalledTimes(1);
|
||||
expect(mockNonReadyFetch).toBeCalledTimes(0);
|
||||
|
||||
expect(results).toMatchSnapshot([
|
||||
{
|
||||
result: {},
|
||||
type: 'ready_col',
|
||||
},
|
||||
{
|
||||
result: {
|
||||
failed: {
|
||||
count: 0,
|
||||
names: [],
|
||||
},
|
||||
fetch_duration_breakdown: [
|
||||
{
|
||||
name: 'ready_col',
|
||||
duration: 0,
|
||||
},
|
||||
],
|
||||
is_ready_duration_breakdown: [
|
||||
{
|
||||
name: 'ready_col',
|
||||
duration: expect.any(Number),
|
||||
},
|
||||
{
|
||||
name: 'timeout_col',
|
||||
duration: expect.any(Number),
|
||||
},
|
||||
],
|
||||
not_ready: {
|
||||
count: 0,
|
||||
names: [],
|
||||
},
|
||||
not_ready_timeout: {
|
||||
count: 1,
|
||||
names: ['timeout_col'],
|
||||
},
|
||||
succeeded: {
|
||||
count: 1,
|
||||
names: ['ready_col'],
|
||||
},
|
||||
total_duration: expect.any(Number),
|
||||
total_fetch_duration: 0,
|
||||
total_is_ready_duration: expect.any(Number),
|
||||
// Passing object instead of array due to https://github.com/facebook/jest/issues/13352
|
||||
expect({ results }).toMatchSnapshot({
|
||||
results: [
|
||||
{
|
||||
result: {},
|
||||
type: 'ready_col',
|
||||
},
|
||||
type: 'usage_collector_stats',
|
||||
},
|
||||
]);
|
||||
{
|
||||
result: {
|
||||
failed: {
|
||||
count: 0,
|
||||
names: [],
|
||||
},
|
||||
fetch_duration_breakdown: [
|
||||
{
|
||||
name: 'ready_col',
|
||||
duration: 0,
|
||||
},
|
||||
],
|
||||
is_ready_duration_breakdown: [
|
||||
{
|
||||
name: 'ready_col',
|
||||
duration: expect.any(Number),
|
||||
},
|
||||
{
|
||||
name: 'timeout_col',
|
||||
duration: expect.any(Number),
|
||||
},
|
||||
],
|
||||
not_ready: {
|
||||
count: 0,
|
||||
names: [],
|
||||
},
|
||||
not_ready_timeout: {
|
||||
count: 1,
|
||||
names: ['timeout_col'],
|
||||
},
|
||||
succeeded: {
|
||||
count: 1,
|
||||
names: ['ready_col'],
|
||||
},
|
||||
total_duration: expect.any(Number),
|
||||
total_fetch_duration: 0,
|
||||
total_is_ready_duration: expect.any(Number),
|
||||
},
|
||||
type: 'usage_collector_stats',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('passes context to fetch', async () => {
|
||||
|
|
|
@ -100,7 +100,7 @@ describe('UsageCountersService', () => {
|
|||
|
||||
coreStart.savedObjects.createInternalRepository.mockReturnValue(mockRepository);
|
||||
const { createUsageCounter } = usageCountersService.setup(coreSetup);
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
const usageCounter = createUsageCounter('test-counter');
|
||||
|
||||
usageCounter.incrementCounter({ counterName: 'counterA' });
|
||||
|
@ -175,7 +175,7 @@ describe('UsageCountersService', () => {
|
|||
|
||||
coreStart.savedObjects.createInternalRepository.mockReturnValue(mockRepository);
|
||||
const { createUsageCounter } = usageCountersService.setup(coreSetup);
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
const usageCounter = createUsageCounter('test-counter');
|
||||
|
||||
usageCountersService.start(coreStart);
|
||||
|
@ -214,7 +214,7 @@ describe('UsageCountersService', () => {
|
|||
coreStart.savedObjects.createInternalRepository.mockReturnValue(mockRepository);
|
||||
|
||||
const { createUsageCounter } = usageCountersService.setup(coreSetup);
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
const usageCounter = createUsageCounter('test-counter');
|
||||
|
||||
usageCountersService.start(coreStart);
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/src/plugins/vis_types/table'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/vis_types/table',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: [
|
||||
|
|
|
@ -95,7 +95,7 @@ describe('useUiState', () => {
|
|||
|
||||
describe('updating uiState through callbacks', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
it('should update the uiState with new sort', async () => {
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
preset: '@kbn/test',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/src/plugins/vis_types/tagcloud'],
|
||||
testRunner: 'jasmine2',
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/vis_types/tagcloud',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/vis_types/tagcloud/{public,server}/**/*.{ts,tsx}'],
|
||||
|
|
|
@ -12,7 +12,7 @@ import { registerClusterCollector } from './register_cluster_collector';
|
|||
import { ActionsPluginsStart } from '../plugin';
|
||||
import { ClusterActionsMetric } from './types';
|
||||
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date('2020-03-09').getTime());
|
||||
|
||||
describe('registerClusterCollector()', () => {
|
||||
|
|
|
@ -80,7 +80,7 @@ describe('AlertingEventLogger', () => {
|
|||
let alertingEventLogger: AlertingEventLogger;
|
||||
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date(mockNow));
|
||||
});
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ const rule = {
|
|||
|
||||
describe('wrapScopedClusterClient', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -35,7 +35,7 @@ const createSearchSourceClientMock = () => {
|
|||
|
||||
describe('wrapSearchSourceClient', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -12,7 +12,7 @@ import { registerClusterCollector } from './register_cluster_collector';
|
|||
import { AlertingPluginsStart } from '../plugin';
|
||||
import { ClusterRulesMetric } from './types';
|
||||
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date('2020-03-09').getTime());
|
||||
|
||||
describe('registerClusterCollector()', () => {
|
||||
|
|
|
@ -15,7 +15,7 @@ const ONE_HOUR = 60 * ONE_MINUTE;
|
|||
|
||||
describe('RuleMonitoringService', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date(mockNow).getTime());
|
||||
});
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('TaskRunnerTimer', () => {
|
|||
|
||||
describe('setDuration', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date('2020-03-09').getTime());
|
||||
});
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ function wrapper({
|
|||
|
||||
describe('useFailedTransactionsCorrelations', () => {
|
||||
beforeEach(async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
// Running all pending timers and switching to real timers using Jest
|
||||
afterEach(() => {
|
||||
|
|
|
@ -95,7 +95,7 @@ function wrapper({
|
|||
|
||||
describe('useLatencyCorrelations', () => {
|
||||
beforeEach(async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
});
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
|
|
|
@ -124,7 +124,7 @@ describe('DatePicker', () => {
|
|||
});
|
||||
|
||||
it('enables auto-refresh when refreshPaused is false', async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
const { wrapper } = mountDatePicker({
|
||||
rangeFrom: 'now-15m',
|
||||
rangeTo: 'now',
|
||||
|
@ -139,7 +139,7 @@ describe('DatePicker', () => {
|
|||
});
|
||||
|
||||
it('disables auto-refresh when refreshPaused is true', async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
mountDatePicker({
|
||||
rangeFrom: 'now-15m',
|
||||
rangeTo: 'now',
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('when simulating race condition', () => {
|
|||
let renderSpy: jest.Mock;
|
||||
|
||||
beforeEach(async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
renderSpy = jest.fn();
|
||||
requestCallOrder = [];
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('useFetcher', () => {
|
|||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
async function fn() {
|
||||
await delay(500);
|
||||
return 'response from hook';
|
||||
|
@ -86,7 +86,7 @@ describe('useFetcher', () => {
|
|||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
async function fn(): Promise<string> {
|
||||
await delay(500);
|
||||
throw new Error('Something went wrong');
|
||||
|
@ -129,7 +129,7 @@ describe('useFetcher', () => {
|
|||
|
||||
describe('when a hook already has data', () => {
|
||||
it('should show "first response" while loading "second response"', async () => {
|
||||
jest.useFakeTimers('legacy');
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
||||
const hook = renderHook(
|
||||
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue