Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## Summary

Bump `[email protected]` and resolve duplicated jest-related dependencies

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
patrykkopycinski and kibanamachine authored Jul 15, 2023
1 parent 2c832d6 commit b2b7cf6
Show file tree
Hide file tree
Showing 54 changed files with 515 additions and 833 deletions.
43 changes: 21 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,10 @@
"@emotion/jest": "^11.11.0",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@istanbuljs/schema": "^0.1.2",
"@jest/console": "^29.3.1",
"@jest/reporters": "^29.3.1",
"@jest/transform": "^29.3.1",
"@jest/types": "^29.3.1",
"@jest/console": "^29.6.1",
"@jest/reporters": "^29.6.1",
"@jest/transform": "^29.6.1",
"@jest/types": "^29.6.1",
"@kbn/alerting-api-integration-helpers": "link:x-pack/test/alerting_api_integration/packages/helpers",
"@kbn/ambient-common-types": "link:packages/kbn-ambient-common-types",
"@kbn/ambient-ftr-types": "link:packages/kbn-ambient-ftr-types",
Expand Down Expand Up @@ -1261,13 +1261,13 @@
"@types/http-proxy": "^1.17.4",
"@types/inquirer": "^7.3.1",
"@types/intl-relativeformat": "^2.1.0",
"@types/jest": "29.2.0",
"@types/jest": "^29.5.3",
"@types/jest-axe": "^3.5.3",
"@types/jquery": "^3.3.31",
"@types/js-levenshtein": "^1.1.0",
"@types/js-search": "^1.4.0",
"@types/js-yaml": "^3.11.1",
"@types/jsdom": "^16.2.14",
"@types/jsdom": "^20.0.1",
"@types/json-schema": "^7",
"@types/json-stable-stringify": "^1.0.32",
"@types/json5": "^2.2.0",
Expand Down Expand Up @@ -1340,7 +1340,7 @@
"@types/tapable": "^1.0.6",
"@types/tar": "^6.1.3",
"@types/tempy": "^0.2.0",
"@types/testing-library__jest-dom": "^5.14.5",
"@types/testing-library__jest-dom": "^5.14.7",
"@types/tinycolor2": "^1.4.1",
"@types/tough-cookie": "^4.0.2",
"@types/type-detect": "^4.0.1",
Expand Down Expand Up @@ -1370,7 +1370,7 @@
"argsplit": "^1.0.5",
"autoprefixer": "^10.4.7",
"axe-core": "^4.6.1",
"babel-jest": "^29.3.1",
"babel-jest": "^29.6.1",
"babel-loader": "^8.2.5",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-istanbul": "^6.1.1",
Expand Down Expand Up @@ -1425,7 +1425,7 @@
"eslint-plugin-react-perf": "^3.3.0",
"eslint-traverse": "^1.0.0",
"exit-hook": "^2.2.0",
"expect": "^29.3.1",
"expect": "^29.6.1",
"expose-loader": "^0.7.5",
"faker": "^5.1.0",
"fetch-mock": "^7.3.9",
Expand All @@ -1444,21 +1444,20 @@
"html-loader": "^1.3.2",
"http-proxy": "^1.18.1",
"is-path-inside": "^3.0.2",
"jest": "^29.3.1",
"jest": "^29.6.1",
"jest-axe": "^5.0.0",
"jest-canvas-mock": "^2.4.0",
"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": "^29.3.1",
"jest-specific-snapshot": "^5.0.0",
"jest-canvas-mock": "^2.5.2",
"jest-cli": "^29.6.1",
"jest-config": "^29.6.1",
"jest-diff": "^29.6.1",
"jest-environment-jsdom": "^29.6.1",
"jest-matcher-utils": "^29.6.1",
"jest-mock": "^29.6.1",
"jest-runtime": "^29.6.1",
"jest-snapshot": "^29.6.1",
"jest-specific-snapshot": "^8.0.0",
"jest-styled-components": "7.0.3",
"jsdom": "^16.4.0",
"jsdom": "^20.0.1",
"json-schema-typed": "^8.0.1",
"json5": "^2.2.3",
"jsondiffpatch": "0.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ describe('#start()', () => {
removeListenerSpy = jest.spyOn(window, 'removeEventListener');
});
afterEach(() => {
jest.restoreAllMocks();
jest.clearAllMocks();
});

it('calls `navigateToApp` with `skipAppLeave` option', async () => {
Expand Down Expand Up @@ -1232,7 +1232,7 @@ describe('#stop()', () => {
});

afterEach(() => {
jest.restoreAllMocks();
jest.clearAllMocks();
});

it('removes the beforeunload listener', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ beforeEach(() => {
});

afterEach(() => {
jest.restoreAllMocks();
jest.clearAllMocks();
mockCreateWriteStream.mockClear();
mockStreamWrite.mockClear();
mockGetFlattenedObject.mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('OsMetricsCollector', () => {
});

afterEach(() => {
jest.restoreAllMocks();
jest.clearAllMocks();
});

it('collects platform info from the os package', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe('plugins discovery system', () => {
afterEach(() => {
mockFs.restore();
// restore the console.log behavior
jest.restoreAllMocks();
jest.clearAllMocks();
});

it('discovers plugins in the search locations', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ beforeEach(() => {
});

afterEach(() => {
jest.restoreAllMocks();
jest.clearAllMocks();
logger.asLoggerFactory.mockClear();
logger.stop.mockClear();
rawConfigService.getConfig$.mockClear();
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/show.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ describe('Kibana keystore: show', () => {
afterEach(() => {
mockLogFn.mockReset();
mockErrFn.mockReset();
jest.restoreAllMocks();
jest.clearAllMocks();
});
});
3 changes: 2 additions & 1 deletion src/plugins/data/common/search/aggs/agg_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('AggConfig', () => {
];

beforeEach(() => {
jest.restoreAllMocks();
jest.clearAllMocks();
indexPattern = {
id: '1234',
title: 'logstash-*',
Expand Down Expand Up @@ -314,6 +314,7 @@ describe('AggConfig', () => {
objs.forEach((obj, i) => {
expect(obj).toHaveProperty('id', String(start + i));
});
spy.mockRestore();
});
});

Expand Down
16 changes: 9 additions & 7 deletions x-pack/plugins/alerting/server/rule_type_registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const inMemoryMetrics = inMemoryMetricsMock.create();
const alertsService = alertsServiceMock.create();

beforeEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
mockedLicenseState = licenseStateMock.create();
ruleTypeRegistryParams = {
logger,
Expand Down Expand Up @@ -97,16 +97,18 @@ describe('Create Lifecycle', () => {

const invalidCharacters = [' ', ':', '*', '*', '/'];
for (const char of invalidCharacters) {
expect(() => registry.register({ ...ruleType, id: `${ruleType.id}${char}` })).toThrowError(
new Error(`expected RuleType Id not to include invalid character: ${char}`)
expect(() =>
registry.register({ ...ruleType, id: `${ruleType.id}${char}` })
).toThrowErrorMatchingInlineSnapshot(
`"expected RuleType Id not to include invalid character: ${char}"`
);
}

const [first, second] = invalidCharacters;
expect(() =>
registry.register({ ...ruleType, id: `${first}${ruleType.id}${second}` })
).toThrowError(
new Error(`expected RuleType Id not to include invalid characters: ${first}, ${second}`)
).toThrowErrorMatchingInlineSnapshot(
`"expected RuleType Id not to include invalid characters: ${first}, ${second}"`
);
});

Expand All @@ -131,8 +133,8 @@ describe('Create Lifecycle', () => {
};
const registry = new RuleTypeRegistry(ruleTypeRegistryParams);

expect(() => registry.register(ruleType)).toThrowError(
new Error(`expected value of type [string] but got [number]`)
expect(() => registry.register(ruleType)).toThrowErrorMatchingInlineSnapshot(
`"expected value of type [string] but got [number]"`
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('useActionTypes', () => {
let appMockRenderer: AppMockRenderer;
beforeEach(() => {
jest.clearAllMocks();
jest.restoreAllMocks();
appMockRenderer = createAppMockRenderer();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('UseFindCaseUserActions', () => {
beforeEach(() => {
appMockRender = createAppMockRenderer();
jest.clearAllMocks();
jest.restoreAllMocks();
});

it('returns proper state on findCaseUserActions', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('useGetActionLicense', () => {
let appMockRenderer: AppMockRenderer;
beforeEach(() => {
jest.clearAllMocks();
jest.restoreAllMocks();
appMockRenderer = createAppMockRenderer();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('useGetCaseMetrics', () => {

beforeEach(() => {
jest.clearAllMocks();
jest.restoreAllMocks();
});

it('calls getSingleCaseMetrics with correct arguments', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('useGetCategories', () => {
const abortCtrl = new AbortController();
beforeEach(() => {
jest.clearAllMocks();
jest.restoreAllMocks();
});

it('calls getCategories api', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('useGetTags', () => {
const abortCtrl = new AbortController();
beforeEach(() => {
jest.clearAllMocks();
jest.restoreAllMocks();
});

it('calls getTags api', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('UseInfiniteFindCaseUserActions', () => {
beforeEach(() => {
appMockRender = createAppMockRenderer();
jest.clearAllMocks();
jest.restoreAllMocks();
});

it('returns proper state on findCaseUserActions', async () => {
Expand Down Expand Up @@ -138,6 +137,7 @@ describe('UseInfiniteFindCaseUserActions', () => {
expect.any(AbortSignal)
);
expect(addError).toHaveBeenCalled();
spy.mockRestore();
});

it('fetches next page with correct params', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jest.mock('../../common/navigation/use_csp_integration_link');
const chance = new Chance();

beforeEach(() => {
jest.restoreAllMocks();
jest.clearAllMocks();

(useSubscriptionStatus as jest.Mock).mockImplementation(() =>
createReactQueryResponse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ services.alertFactory.create.mockImplementation((instanceID: string) => {
: newAlertInstance;
alertInstances.set(instanceID, alertInstance);

alertInstance.instance.scheduleActions.mockImplementation((id: string, action: any) => {
alertInstance.actionQueue.push({ id, action });
return alertInstance.instance;
});
(alertInstance.instance.scheduleActions as jest.Mock).mockImplementation(
(id: string, action: any) => {
alertInstance.actionQueue.push({ id, action });
return alertInstance.instance;
}
);

return alertInstance.instance;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1961,10 +1961,12 @@ services.alertFactory.create.mockImplementation((instanceID: string) => {
alertInstance.state = newState;
return alertInstance.instance;
});
alertInstance.instance.scheduleActions.mockImplementation((id: string, action: any) => {
alertInstance.actionQueue.push({ id, action });
return alertInstance.instance;
});
(alertInstance.instance.scheduleActions as jest.Mock).mockImplementation(
(id: string, action: any) => {
alertInstance.actionQueue.push({ id, action });
return alertInstance.instance;
}
);
return alertInstance.instance;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1932,10 +1932,12 @@ services.alertFactory.create.mockImplementation((instanceID: string) => {
alertInstance.state = newState;
return alertInstance.instance;
});
alertInstance.instance.scheduleActions.mockImplementation((id: string, action: any) => {
alertInstance.actionQueue.push({ id, action });
return alertInstance.instance;
});
(alertInstance.instance.scheduleActions as jest.Mock).mockImplementation(
(id: string, action: any) => {
alertInstance.actionQueue.push({ id, action });
return alertInstance.instance;
}
);
return alertInstance.instance;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe(`GET ${API_GET_ILM_POLICY_STATUS}`, () => {
});

afterEach(async () => {
jest.restoreAllMocks();
await server.stop();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe('POST /diagnose/browser', () => {
});

afterEach(async () => {
jest.restoreAllMocks();
await server.stop();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('SessionManagementService', () => {
});

afterEach(() => {
mockSessionIndexInitialize.mockReset();
mockSessionIndexCleanUp.mockReset();
mockSessionIndexInitialize.mockClear();
mockSessionIndexCleanUp.mockClear();
});

describe('setup()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ describe('Sourcerer component', () => {
(useSignalHelpers as jest.Mock).mockReturnValue({ signalIndexNeedsInit: false });
});

afterAll(() => {
jest.restoreAllMocks();
});

it('renders data view title', () => {
const wrapper = mount(
<TestProviders store={store}>
Expand Down Expand Up @@ -896,8 +892,8 @@ describe('Sourcerer integration tests', () => {
(useSourcererDataView as jest.Mock).mockReturnValue(sourcererDataView);
store = createStore(state, SUB_PLUGINS_REDUCER, kibanaObservable, storage);
jest.clearAllMocks();
jest.restoreAllMocks();
});

it('Selects a different index pattern', async () => {
const wrapper = mount(
<TestProviders store={store}>
Expand Down Expand Up @@ -941,8 +937,8 @@ describe('No data', () => {
});
store = createStore(mockNoIndicesState, SUB_PLUGINS_REDUCER, kibanaObservable, storage);
jest.clearAllMocks();
jest.restoreAllMocks();
});

test('Hide sourcerer - default ', () => {
const wrapper = mount(
<TestProviders store={store}>
Expand Down
Loading

0 comments on commit b2b7cf6

Please sign in to comment.