Skip to content

Commit

Permalink
Bumps Jest related packages (#78720)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
  • Loading branch information
Tyler Smalley authored Oct 1, 2020
1 parent 63ff060 commit 7211f78
Show file tree
Hide file tree
Showing 42 changed files with 978 additions and 932 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
"@types/hjson": "^2.4.2",
"@types/hoek": "^4.1.3",
"@types/inert": "^5.1.2",
"@types/jest": "^25.2.3",
"@types/jest": "^26.0.14",
"@types/jest-when": "^2.7.1",
"@types/joi": "^13.4.2",
"@types/jquery": "^3.3.31",
Expand Down Expand Up @@ -337,7 +337,7 @@
"@types/supertest-as-promised": "^2.0.38",
"@types/tapable": "^1.0.6",
"@types/tar": "^4.0.3",
"@types/testing-library__jest-dom": "^5.9.2",
"@types/testing-library__jest-dom": "^5.9.3",
"@types/testing-library__react-hooks": "^3.4.0",
"@types/type-detect": "^4.0.1",
"@types/uuid": "^3.4.4",
Expand All @@ -356,7 +356,7 @@
"archiver": "^3.1.1",
"axe-core": "^4.0.2",
"babel-eslint": "^10.0.3",
"babel-jest": "^25.5.1",
"babel-jest": "^26.3.0",
"babel-plugin-istanbul": "^6.0.0",
"backport": "5.6.0",
"brace": "0.11.1",
Expand All @@ -382,7 +382,7 @@
"eslint-plugin-cypress": "^2.8.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jest": "^23.10.0",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-no-unsanitized": "^3.0.2",
Expand Down Expand Up @@ -411,10 +411,10 @@
"iedriver": "^3.14.2",
"immer": "^1.5.0",
"intl-messageformat-parser": "^1.4.0",
"jest": "^25.5.4",
"jest": "^26.4.2",
"jest-canvas-mock": "^2.2.0",
"jest-circus": "^25.5.4",
"jest-cli": "^25.5.4",
"jest-circus": "^26.4.2",
"jest-cli": "^26.4.2",
"jest-environment-jsdom-thirteen": "^1.0.1",
"jest-raw-loader": "^1.0.1",
"jest-when": "^2.7.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/elastic-eslint-config-kibana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jest": "^23.10.0",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es/src/integration_tests/cluster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function ensureResolve(promise) {

function mockEsBin({ exitCode, start }) {
execa.mockImplementationOnce((cmd, args, options) =>
require.requireActual('execa')(
jest.requireActual('execa')(
process.execPath,
[
require.resolve('./__fixtures__/es_bin.js'),
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-i18n/src/core/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('I18n engine', () => {
let i18n: typeof i18nModule;

beforeEach(() => {
i18n = require.requireActual('./i18n');
i18n = jest.requireActual('./i18n');
});

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"execa": "^4.0.2",
"file-loader": "^4.2.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jest-diff": "^25.5.0",
"jest-diff": "^26.4.2",
"json-stable-stringify": "^1.0.1",
"loader-utils": "^1.2.3",
"node-sass": "^4.13.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-spec-to-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"homepage": "https://github.com/jbudz/spec-to-console#readme",
"devDependencies": {
"jest": "^25.5.4",
"jest": "^26.4.2",
"prettier": "^2.1.1"
},
"dependencies": {
Expand Down
6 changes: 2 additions & 4 deletions src/legacy/server/logging/rotate/log_rotator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import fs, { existsSync, mkdirSync, statSync, writeFileSync } from 'fs';
import { LogRotator } from './log_rotator';
import { tmpdir } from 'os';
import { dirname, join } from 'path';
import lodash from 'lodash';

const mockOn = jest.fn();
jest.mock('chokidar', () => ({
Expand All @@ -31,10 +32,7 @@ jest.mock('chokidar', () => ({
})),
}));

jest.mock('lodash', () => ({
...require.requireActual('lodash'),
throttle: (fn: any) => fn,
}));
lodash.throttle = (fn: any) => fn;

const tempDir = join(tmpdir(), 'kbn_log_rotator_test');
const testFilePath = join(tempDir, 'log_rotator_test_log_file.log');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
jest.mock(
'lodash',
() => ({
...require.requireActual('lodash'),
...jest.requireActual('lodash'),
// mock debounce to fire immediately with no internal timer
debounce: (func) => {
function debounced(...args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jest.mock('./components/time_field', () => ({ TimeField: 'TimeField' }));
jest.mock('./components/advanced_options', () => ({ AdvancedOptions: 'AdvancedOptions' }));
jest.mock('./components/action_buttons', () => ({ ActionButtons: 'ActionButtons' }));
jest.mock('./../../lib', () => ({
extractTimeFields: require.requireActual('./../../lib').extractTimeFields,
extractTimeFields: jest.requireActual('./../../lib').extractTimeFields,
ensureMinimumTime: async (fields: IFieldType) => Promise.resolve(fields),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jest.mock('@elastic/eui', () => ({
let counter = 1;
return () => `12${counter++}`;
}),
EuiSpacer: require.requireActual('@elastic/eui').EuiSpacer,
EuiFlexItem: require.requireActual('@elastic/eui').EuiFlexItem,
EuiButtonEmpty: require.requireActual('@elastic/eui').EuiButtonEmpty,
EuiFormErrorText: require.requireActual('@elastic/eui').EuiFormErrorText,
EuiSpacer: jest.requireActual('@elastic/eui').EuiSpacer,
EuiFlexItem: jest.requireActual('@elastic/eui').EuiFlexItem,
EuiButtonEmpty: jest.requireActual('@elastic/eui').EuiButtonEmpty,
EuiFormErrorText: jest.requireActual('@elastic/eui').EuiFormErrorText,
}));

describe('NumberList', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import { SplitByTermsUI } from './terms';

jest.mock('@elastic/eui', () => ({
htmlIdGenerator: jest.fn(() => () => '42'),
EuiFlexGroup: require.requireActual('@elastic/eui').EuiFlexGroup,
EuiFlexItem: require.requireActual('@elastic/eui').EuiFlexItem,
EuiFormRow: require.requireActual('@elastic/eui').EuiFormRow,
EuiFieldNumber: require.requireActual('@elastic/eui').EuiFieldNumber,
EuiComboBox: require.requireActual('@elastic/eui').EuiComboBox,
EuiFieldText: require.requireActual('@elastic/eui').EuiFieldText,
EuiFlexGroup: jest.requireActual('@elastic/eui').EuiFlexGroup,
EuiFlexItem: jest.requireActual('@elastic/eui').EuiFlexItem,
EuiFormRow: jest.requireActual('@elastic/eui').EuiFormRow,
EuiFieldNumber: jest.requireActual('@elastic/eui').EuiFieldNumber,
EuiComboBox: jest.requireActual('@elastic/eui').EuiComboBox,
EuiFieldText: jest.requireActual('@elastic/eui').EuiFieldText,
}));

describe('src/legacy/core_plugins/metrics/public/components/splits/terms.test.js', () => {
Expand Down
12 changes: 6 additions & 6 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@types/hoist-non-react-statics": "^3.3.1",
"@types/http-proxy": "^1.17.4",
"@types/http-proxy-agent": "^2.0.2",
"@types/jest": "^25.2.3",
"@types/jest": "^26.0.14",
"@types/jest-specific-snapshot": "^0.5.4",
"@types/joi": "^13.4.2",
"@types/js-search": "^1.4.0",
Expand Down Expand Up @@ -127,7 +127,7 @@
"@types/styled-components": "^5.1.0",
"@types/supertest": "^2.0.5",
"@types/tar-fs": "^1.16.1",
"@types/testing-library__jest-dom": "^5.9.2",
"@types/testing-library__jest-dom": "^5.9.3",
"@types/testing-library__react-hooks": "^3.4.0",
"@types/tinycolor2": "^1.4.1",
"@types/use-resize-observer": "^6.0.0",
Expand All @@ -143,7 +143,7 @@
"apollo-link-error": "^1.1.7",
"apollo-link-state": "^0.4.1",
"autoprefixer": "^9.7.4",
"babel-jest": "^25.5.1",
"babel-jest": "^26.3.0",
"babel-loader": "^8.0.6",
"babel-plugin-require-context-hook": "npm:babel-plugin-require-context-hook-babel7@1.0.0",
"base64-js": "^1.3.1",
Expand Down Expand Up @@ -188,9 +188,9 @@
"hoist-non-react-statics": "^3.3.2",
"i18n-iso-countries": "^4.3.1",
"icalendar": "0.7.1",
"jest": "^25.5.4",
"jest-circus": "^25.5.4",
"jest-cli": "^25.5.4",
"jest": "^26.4.2",
"jest-circus": "^26.4.2",
"jest-cli": "^26.4.2",
"jest-styled-components": "^7.0.2",
"js-search": "^1.4.3",
"jsdom": "13.1.0",
Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/alerts/server/alerts_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4130,14 +4130,13 @@ describe('update()', () => {
expect(taskManager.runNow).not.toHaveBeenCalled();
});

test('updating the alert should not wait for the rerun the task to complete', async (done) => {
test('updating the alert should not wait for the rerun the task to complete', async () => {
const alertId = uuid.v4();
const taskId = uuid.v4();

mockApiCalls(alertId, taskId, { interval: '10s' }, { interval: '30s' });

const resolveAfterAlertUpdatedCompletes = resolvable<{ id: string }>();
resolveAfterAlertUpdatedCompletes.then(() => done());

taskManager.runNow.mockReset();
taskManager.runNow.mockReturnValue(resolveAfterAlertUpdatedCompletes);
Expand Down Expand Up @@ -4165,7 +4164,6 @@ describe('update()', () => {
});

expect(taskManager.runNow).toHaveBeenCalled();

resolveAfterAlertUpdatedCompletes.resolve({ id: alertId });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jest.mock('@elastic/eui/lib/components/portal/portal', () => {
// Local constants are not supported in Jest mocks-- they must be
// imported within the mock.
// eslint-disable-next-line no-shadow
const React = require.requireActual('react');
const React = jest.requireActual('react');
return {
EuiPortal: (props: any) => <div>{props.children}</div>,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jest.mock('@elastic/eui/lib/services/accessibility', () => {
});
jest.mock('@elastic/eui/lib/components/portal/portal', () => {
// eslint-disable-next-line no-shadow
const React = require.requireActual('react');
const React = jest.requireActual('react');
return {
EuiPortal: (props: any) => <div>{props.children}</div>,
};
Expand Down
27 changes: 4 additions & 23 deletions x-pack/plugins/event_log/server/lib/ready_signal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,9 @@ describe('ReadySignal', () => {
readySignal = createReadySignal<number>();
});

test('works as expected', async (done) => {
let value = 41;

timeoutSet(100, async () => {
expect(value).toBe(41);
});

timeoutSet(250, async () => readySignal.signal(42));

timeoutSet(400, async () => {
expect(value).toBe(42);

const innerValue = await readySignal.wait();
expect(innerValue).toBe(42);
done();
});

value = await readySignal.wait();
expect(value).toBe(42);
test('works as expected', async () => {
readySignal.signal(42);
const ready = await readySignal.wait();
expect(ready).toBe(42);
});
});

function timeoutSet(ms: number, fn: () => Promise<unknown>): void {
setTimeout(fn, ms);
}
32 changes: 11 additions & 21 deletions x-pack/plugins/licensing/public/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { take } from 'rxjs/operators';
import { take, toArray } from 'rxjs/operators';
import { mountExpiredBannerMock } from './plugin.test.mocks';

import { LicenseType } from '../common/types';
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('licensing plugin', () => {
expect(sessionStorage.getItem).toHaveBeenCalledWith(licensingSessionStorageKey);
});

it('observable receives updated licenses', async (done) => {
it('observable receives updated licenses', async () => {
const types: LicenseType[] = ['gold', 'platinum'];

const sessionStorage = coreMock.createStorage();
Expand All @@ -104,27 +104,17 @@ describe('licensing plugin', () => {
Promise.resolve(licenseMock.createLicense({ license: { type: types.shift() } }))
);

await plugin.setup(coreSetup);
plugin.setup(coreSetup);
const { refresh, license$ } = await plugin.start(coreStart);
const promise = license$.pipe(take(3), toArray()).toPromise();

let i = 0;
license$.subscribe((value) => {
i++;
if (i === 1) {
expect(value.type).toBe('basic');
refresh();
} else if (i === 2) {
expect(value.type).toBe('gold');
// since this is a synchronous subscription, we need to give the exhaustMap a chance
// to mark the subscription as complete before emitting another value on the Subject
process.nextTick(() => refresh());
} else if (i === 3) {
expect(value.type).toBe('platinum');
done();
} else {
throw new Error('unreachable');
}
});
await refresh();
await refresh();

const licenses = await promise;
expect(licenses[0].type).toBe('basic');
expect(licenses[1].type).toBe('gold');
expect(licenses[2].type).toBe('platinum');
});

it('saved fetched license & signature in session storage', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ describe('ml_server_info initial state', () => {
});

describe('ml_server_info', () => {
beforeEach(async (done) => {
beforeEach(async () => {
await loadMlServerInfo();
done();
});

describe('cloud information', () => {
Expand All @@ -41,23 +40,21 @@ describe('ml_server_info', () => {
});

describe('defaults', () => {
it('should get defaults', async (done) => {
it('should get defaults', async () => {
const defaults = getNewJobDefaults();

expect(defaults.anomaly_detectors.model_memory_limit).toBe('128mb');
expect(defaults.anomaly_detectors.categorization_examples_limit).toBe(4);
expect(defaults.anomaly_detectors.model_snapshot_retention_days).toBe(1);
expect(defaults.datafeeds.scroll_size).toBe(1000);
done();
});
});

describe('limits', () => {
it('should get limits', async (done) => {
it('should get limits', async () => {
const limits = getNewJobLimits();

expect(limits.max_model_memory_limit).toBe('128mb');
done();
});
});

Expand Down
Loading

0 comments on commit 7211f78

Please sign in to comment.