From 8e87306acc36d71fe0d9aabe396d49dc3188153e Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 9 Nov 2021 11:25:25 -0800 Subject: [PATCH 1/2] [ci] Run Jest tests in parallel (#117188) Signed-off-by: Tyler Smalley --- .buildkite/pipelines/hourly.yml | 15 +++++----- .buildkite/pipelines/pull_request/base.yml | 15 +++++----- .buildkite/scripts/steps/test/jest.sh | 4 +-- .../scripts/steps/test/jest_parallel.sh | 30 +++++++++++++++++++ .eslintrc.js | 1 + jest.config.js | 3 ++ .../kbn-cli-dev-mode/src/dev_server.test.ts | 6 ++-- packages/kbn-rule-data-utils/jest.config.js | 13 -------- .../jest.config.js | 13 -------- .../kbn-securitysolution-rules/jest.config.js | 13 -------- .../jest.config.js | 13 -------- packages/kbn-test/jest-preset.js | 10 ++++++- packages/kbn-test/src/jest/run.ts | 5 ++-- .../src/jest/run_check_jest_configs_cli.ts | 15 ++++++++-- src/plugins/expression_error/jest.config.js | 16 ---------- .../download/ensure_downloaded.test.ts | 3 +- .../server/routes/deprecations.test.ts | 3 +- .../common}/jest.config.js | 11 +++---- .../public/app/jest.config.js | 16 ++++++++++ .../public/cases/jest.config.js | 16 ++++++++++ .../events_viewer/events_viewer.test.tsx | 17 ++++------- .../public/common/jest.config.js | 16 ++++++++++ .../public/detections/jest.config.js | 18 +++++++++++ .../public/hosts/jest.config.js | 16 ++++++++++ .../security_solution/public/jest.config.js | 18 +++++++++++ .../public/management/jest.config.js | 18 +++++++++++ .../public/network/jest.config.js | 16 ++++++++++ .../public/overview/jest.config.js | 16 ++++++++++ .../public/resolver/jest.config.js | 16 ++++++++++ .../{ => public/timelines}/jest.config.js | 9 +++--- .../public/transforms/jest.config.js | 18 +++++++++++ .../server/client/jest.config.js | 16 ++++++++++ .../server/endpoint/jest.config.js | 16 ++++++++++ .../server/fleet_integration/jest.config.js | 18 +++++++++++ .../security_solution/server/jest.config.js | 18 +++++++++++ .../server/lib/jest.config.js | 16 ++++++++++ .../server/search_strategy/jest.config.js | 18 +++++++++++ .../server/usage/jest.config.js | 16 ++++++++++ .../server/utils/jest.config.js | 16 ++++++++++ 39 files changed, 420 insertions(+), 113 deletions(-) create mode 100755 .buildkite/scripts/steps/test/jest_parallel.sh delete mode 100644 packages/kbn-rule-data-utils/jest.config.js delete mode 100644 packages/kbn-securitysolution-list-constants/jest.config.js delete mode 100644 packages/kbn-securitysolution-rules/jest.config.js delete mode 100644 packages/kbn-securitysolution-t-grid/jest.config.js delete mode 100644 src/plugins/expression_error/jest.config.js rename x-pack/plugins/{metrics_entities => security_solution/common}/jest.config.js (53%) create mode 100644 x-pack/plugins/security_solution/public/app/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/cases/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/common/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/detections/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/hosts/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/management/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/network/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/overview/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/resolver/jest.config.js rename x-pack/plugins/security_solution/{ => public/timelines}/jest.config.js (55%) create mode 100644 x-pack/plugins/security_solution/public/transforms/jest.config.js create mode 100644 x-pack/plugins/security_solution/server/client/jest.config.js create mode 100644 x-pack/plugins/security_solution/server/endpoint/jest.config.js create mode 100644 x-pack/plugins/security_solution/server/fleet_integration/jest.config.js create mode 100644 x-pack/plugins/security_solution/server/jest.config.js create mode 100644 x-pack/plugins/security_solution/server/lib/jest.config.js create mode 100644 x-pack/plugins/security_solution/server/search_strategy/jest.config.js create mode 100644 x-pack/plugins/security_solution/server/usage/jest.config.js create mode 100644 x-pack/plugins/security_solution/server/utils/jest.config.js diff --git a/.buildkite/pipelines/hourly.yml b/.buildkite/pipelines/hourly.yml index 4b2b17d272d17e..9e9990816ad1d9 100644 --- a/.buildkite/pipelines/hourly.yml +++ b/.buildkite/pipelines/hourly.yml @@ -119,6 +119,14 @@ steps: - exit_status: '*' limit: 1 + - command: .buildkite/scripts/steps/test/jest.sh + label: 'Jest Tests' + parallelism: 8 + agents: + queue: n2-4 + timeout_in_minutes: 90 + key: jest + - command: .buildkite/scripts/steps/test/jest_integration.sh label: 'Jest Integration Tests' agents: @@ -133,13 +141,6 @@ steps: timeout_in_minutes: 120 key: api-integration - - command: .buildkite/scripts/steps/test/jest.sh - label: 'Jest Tests' - agents: - queue: c2-16 - timeout_in_minutes: 120 - key: jest - - command: .buildkite/scripts/steps/lint.sh label: 'Linting' agents: diff --git a/.buildkite/pipelines/pull_request/base.yml b/.buildkite/pipelines/pull_request/base.yml index 0f2a4a1026af87..34db52772e6192 100644 --- a/.buildkite/pipelines/pull_request/base.yml +++ b/.buildkite/pipelines/pull_request/base.yml @@ -117,6 +117,14 @@ steps: - exit_status: '*' limit: 1 + - command: .buildkite/scripts/steps/test/jest.sh + label: 'Jest Tests' + parallelism: 8 + agents: + queue: n2-4 + timeout_in_minutes: 90 + key: jest + - command: .buildkite/scripts/steps/test/jest_integration.sh label: 'Jest Integration Tests' agents: @@ -131,13 +139,6 @@ steps: timeout_in_minutes: 120 key: api-integration - - command: .buildkite/scripts/steps/test/jest.sh - label: 'Jest Tests' - agents: - queue: c2-16 - timeout_in_minutes: 120 - key: jest - - command: .buildkite/scripts/steps/lint.sh label: 'Linting' agents: diff --git a/.buildkite/scripts/steps/test/jest.sh b/.buildkite/scripts/steps/test/jest.sh index 2c4e3fe21902d0..d2d1ed10043d6b 100755 --- a/.buildkite/scripts/steps/test/jest.sh +++ b/.buildkite/scripts/steps/test/jest.sh @@ -9,5 +9,5 @@ is_test_execution_step .buildkite/scripts/bootstrap.sh echo '--- Jest' -checks-reporter-with-killswitch "Jest Unit Tests" \ - node scripts/jest --ci --verbose --maxWorkers=10 +checks-reporter-with-killswitch "Jest Unit Tests $((BUILDKITE_PARALLEL_JOB+1))" \ + .buildkite/scripts/steps/test/jest_parallel.sh diff --git a/.buildkite/scripts/steps/test/jest_parallel.sh b/.buildkite/scripts/steps/test/jest_parallel.sh new file mode 100755 index 00000000000000..c9e0e1aff5cf2f --- /dev/null +++ b/.buildkite/scripts/steps/test/jest_parallel.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -uo pipefail + +JOB=$BUILDKITE_PARALLEL_JOB +JOB_COUNT=$BUILDKITE_PARALLEL_JOB_COUNT + +# a jest failure will result in the script returning an exit code of 10 + +i=0 +exitCode=0 + +while read -r config; do + if [ "$((i % JOB_COUNT))" -eq "$JOB" ]; then + echo "--- $ node scripts/jest --config $config" + node --max-old-space-size=14336 ./node_modules/.bin/jest --config="$config" --runInBand --coverage=false + lastCode=$? + + if [ $lastCode -ne 0 ]; then + exitCode=10 + echo "Jest exited with code $lastCode" + echo "^^^ +++" + fi + fi + + ((i=i+1)) +# uses heredoc to avoid the while loop being in a sub-shell thus unable to overwrite exitCode +done <<< "$(find src x-pack packages -name jest.config.js -not -path "*/__fixtures__/*" | sort)" + +exit $exitCode \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 0064fed40637c6..18c54069e25d54 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -704,6 +704,7 @@ module.exports = { 'packages/kbn-eslint-plugin-eslint/**/*', 'x-pack/gulpfile.js', 'x-pack/scripts/*.js', + '**/jest.config.js', ], excludedFiles: ['**/integration_tests/**/*'], rules: { diff --git a/jest.config.js b/jest.config.js index 09532dc28bbb2b..ae07034c10781d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,5 +17,8 @@ module.exports = { '/src/plugins/vis_types/*/jest.config.js', '/test/*/jest.config.js', '/x-pack/plugins/*/jest.config.js', + '/x-pack/plugins/security_solution/*/jest.config.js', + '/x-pack/plugins/security_solution/public/*/jest.config.js', + '/x-pack/plugins/security_solution/server/*/jest.config.js', ], }; diff --git a/packages/kbn-cli-dev-mode/src/dev_server.test.ts b/packages/kbn-cli-dev-mode/src/dev_server.test.ts index 92dbe484eb0058..5e386e3de59726 100644 --- a/packages/kbn-cli-dev-mode/src/dev_server.test.ts +++ b/packages/kbn-cli-dev-mode/src/dev_server.test.ts @@ -79,6 +79,7 @@ expect.addSnapshotSerializer(extendedEnvSerializer); beforeEach(() => { jest.clearAllMocks(); log.messages.length = 0; + process.execArgv = ['--inheritted', '--exec', '--argv']; currentProc = undefined; }); @@ -138,8 +139,9 @@ describe('#run$', () => { "isDevCliChild": "true", }, "nodeOptions": Array [ - "--preserve-symlinks-main", - "--preserve-symlinks", + "--inheritted", + "--exec", + "--argv", ], "stdio": "pipe", }, diff --git a/packages/kbn-rule-data-utils/jest.config.js b/packages/kbn-rule-data-utils/jest.config.js deleted file mode 100644 index 26cb39fe8b55ae..00000000000000 --- a/packages/kbn-rule-data-utils/jest.config.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * 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 = { - preset: '@kbn/test', - rootDir: '../..', - roots: ['/packages/kbn-rule-data-utils'], -}; diff --git a/packages/kbn-securitysolution-list-constants/jest.config.js b/packages/kbn-securitysolution-list-constants/jest.config.js deleted file mode 100644 index 21dffdfcf5a68a..00000000000000 --- a/packages/kbn-securitysolution-list-constants/jest.config.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * 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 = { - preset: '@kbn/test', - rootDir: '../..', - roots: ['/packages/kbn-securitysolution-list-constants'], -}; diff --git a/packages/kbn-securitysolution-rules/jest.config.js b/packages/kbn-securitysolution-rules/jest.config.js deleted file mode 100644 index 99368edd5372cc..00000000000000 --- a/packages/kbn-securitysolution-rules/jest.config.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * 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 = { - preset: '@kbn/test', - rootDir: '../..', - roots: ['/packages/kbn-securitysolution-rules'], -}; diff --git a/packages/kbn-securitysolution-t-grid/jest.config.js b/packages/kbn-securitysolution-t-grid/jest.config.js deleted file mode 100644 index 21e7d2d71b61a1..00000000000000 --- a/packages/kbn-securitysolution-t-grid/jest.config.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * 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 = { - preset: '@kbn/test', - rootDir: '../..', - roots: ['/packages/kbn-securitysolution-t-grid'], -}; diff --git a/packages/kbn-test/jest-preset.js b/packages/kbn-test/jest-preset.js index 0199aa6e311b6f..db64f070b37d9b 100644 --- a/packages/kbn-test/jest-preset.js +++ b/packages/kbn-test/jest-preset.js @@ -46,7 +46,15 @@ module.exports = { modulePathIgnorePatterns: ['__fixtures__/', 'target/'], // Use this configuration option to add custom reporters to Jest - reporters: ['default', '@kbn/test/target_node/jest/junit_reporter'], + reporters: [ + 'default', + [ + '@kbn/test/target_node/jest/junit_reporter', + { + rootDirectory: '.', + }, + ], + ], // The paths to modules that run some code to configure or set up the testing environment before each test setupFiles: [ diff --git a/packages/kbn-test/src/jest/run.ts b/packages/kbn-test/src/jest/run.ts index 4a5dd4e9281baf..f2592500beeee6 100644 --- a/packages/kbn-test/src/jest/run.ts +++ b/packages/kbn-test/src/jest/run.ts @@ -52,11 +52,12 @@ export function runJest(configName = 'jest.config.js') { const runStartTime = Date.now(); const reportTime = getTimeReporter(log, 'scripts/jest'); - let cwd: string; + let testFiles: string[]; + const cwd: string = process.env.INIT_CWD || process.cwd(); + if (!argv.config) { - cwd = process.env.INIT_CWD || process.cwd(); testFiles = argv._.splice(2).map((p) => resolve(cwd, p)); const commonTestFiles = commonBasePath(testFiles); const testFilesProvided = testFiles.length > 0; diff --git a/packages/kbn-test/src/jest/run_check_jest_configs_cli.ts b/packages/kbn-test/src/jest/run_check_jest_configs_cli.ts index 5895ef193fbfe2..cf37ee82d61e9c 100644 --- a/packages/kbn-test/src/jest/run_check_jest_configs_cli.ts +++ b/packages/kbn-test/src/jest/run_check_jest_configs_cli.ts @@ -26,7 +26,16 @@ const template: string = `module.exports = { }; `; -const roots: string[] = ['x-pack/plugins', 'packages', 'src/plugins', 'test', 'src']; +const roots: string[] = [ + 'x-pack/plugins/security_solution/public', + 'x-pack/plugins/security_solution/server', + 'x-pack/plugins/security_solution', + 'x-pack/plugins', + 'packages', + 'src/plugins', + 'test', + 'src', +]; export async function runCheckJestConfigsCli() { run( @@ -76,7 +85,9 @@ export async function runCheckJestConfigsCli() { modulePath, }); - writeFileSync(resolve(root, name, 'jest.config.js'), content); + const configPath = resolve(root, name, 'jest.config.js'); + log.info('created %s', configPath); + writeFileSync(configPath, content); } else { log.warning(`Unable to determind where to place jest.config.js for ${file}`); } diff --git a/src/plugins/expression_error/jest.config.js b/src/plugins/expression_error/jest.config.js deleted file mode 100644 index 27774f4003f9e1..00000000000000 --- a/src/plugins/expression_error/jest.config.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 = { - preset: '@kbn/test', - rootDir: '../../..', - roots: ['/src/plugins/expression_error'], - coverageDirectory: '/target/kibana-coverage/jest/src/plugins/expression_error', - coverageReporters: ['text', 'html'], - collectCoverageFrom: ['/src/plugins/expression_error/{common,public}/**/*.{ts,tsx}'], -}; diff --git a/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.test.ts b/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.test.ts index 955e8214af8fa1..9db128c019ac07 100644 --- a/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.test.ts +++ b/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.test.ts @@ -17,7 +17,8 @@ import { LevelLogger } from '../../lib'; jest.mock('./checksum'); jest.mock('./download'); -describe('ensureBrowserDownloaded', () => { +// https://github.com/elastic/kibana/issues/115881 +describe.skip('ensureBrowserDownloaded', () => { let logger: jest.Mocked; beforeEach(() => { diff --git a/x-pack/plugins/reporting/server/routes/deprecations.test.ts b/x-pack/plugins/reporting/server/routes/deprecations.test.ts index 5367b6bd531eda..63be2acf52c259 100644 --- a/x-pack/plugins/reporting/server/routes/deprecations.test.ts +++ b/x-pack/plugins/reporting/server/routes/deprecations.test.ts @@ -24,7 +24,8 @@ import { registerDeprecationsRoutes } from './deprecations'; type SetupServerReturn = UnwrapPromise>; -describe(`GET ${API_GET_ILM_POLICY_STATUS}`, () => { +// https://github.com/elastic/kibana/issues/115881 +describe.skip(`GET ${API_GET_ILM_POLICY_STATUS}`, () => { const reportingSymbol = Symbol('reporting'); let server: SetupServerReturn['server']; let httpSetup: SetupServerReturn['httpSetup']; diff --git a/x-pack/plugins/metrics_entities/jest.config.js b/x-pack/plugins/security_solution/common/jest.config.js similarity index 53% rename from x-pack/plugins/metrics_entities/jest.config.js rename to x-pack/plugins/security_solution/common/jest.config.js index 98a391223cc0f9..ca6f7cd368f2b3 100644 --- a/x-pack/plugins/metrics_entities/jest.config.js +++ b/x-pack/plugins/security_solution/common/jest.config.js @@ -6,10 +6,11 @@ */ module.exports = { - collectCoverageFrom: ['/x-pack/plugins/metrics_entities/{common,server}/**/*.{ts,tsx}'], - coverageDirectory: '/target/kibana-coverage/jest/x-pack/plugins/metrics_entities', - coverageReporters: ['text', 'html'], preset: '@kbn/test', - rootDir: '../../..', - roots: ['/x-pack/plugins/metrics_entities'], + rootDir: '../../../..', + roots: ['/x-pack/plugins/security_solution/common'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/common', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/common/**/*.{ts,tsx}'], }; diff --git a/x-pack/plugins/security_solution/public/app/jest.config.js b/x-pack/plugins/security_solution/public/app/jest.config.js new file mode 100644 index 00000000000000..452cee5e5b3a6d --- /dev/null +++ b/x-pack/plugins/security_solution/public/app/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/app'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/app', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/public/app/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/public/cases/jest.config.js b/x-pack/plugins/security_solution/public/cases/jest.config.js new file mode 100644 index 00000000000000..4b0a49fd65afff --- /dev/null +++ b/x-pack/plugins/security_solution/public/cases/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/cases'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/cases', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/public/cases/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/events_viewer.test.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/events_viewer.test.tsx index a611d140f61d13..cc94f24d040248 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/events_viewer.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/events_viewer.test.tsx @@ -184,7 +184,7 @@ describe('EventsViewer', () => { mockUseTimelineEvents.mockReturnValue([false, mockEventViewerResponseWithEvents]); }); - test('call the right reduce action to show event details', () => { + test('call the right reduce action to show event details', async () => { const wrapper = mount( @@ -195,19 +195,14 @@ describe('EventsViewer', () => { wrapper.find(`[data-test-subj="expand-event"]`).first().simulate('click'); }); - waitFor(() => { - expect(mockDispatch).toBeCalledTimes(2); + await waitFor(() => { + expect(mockDispatch).toBeCalledTimes(3); expect(mockDispatch.mock.calls[1][0]).toEqual({ payload: { - panelView: 'eventDetail', - params: { - eventId: 'yb8TkHYBRgU82_bJu_rY', - indexName: 'auditbeat-7.10.1-2020.12.18-000001', - }, - tabType: 'query', - timelineId: TimelineId.test, + id: 'test', + isLoading: false, }, - type: 'x-pack/security_solution/local/timeline/TOGGLE_DETAIL_PANEL', + type: 'x-pack/timelines/t-grid/UPDATE_LOADING', }); }); }); diff --git a/x-pack/plugins/security_solution/public/common/jest.config.js b/x-pack/plugins/security_solution/public/common/jest.config.js new file mode 100644 index 00000000000000..e59f9c68f7590a --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/common'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/common', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/public/common/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/public/detections/jest.config.js b/x-pack/plugins/security_solution/public/detections/jest.config.js new file mode 100644 index 00000000000000..23bc914b6493bb --- /dev/null +++ b/x-pack/plugins/security_solution/public/detections/jest.config.js @@ -0,0 +1,18 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/detections'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/detections', + coverageReporters: ['text', 'html'], + collectCoverageFrom: [ + '/x-pack/plugins/security_solution/public/detections/**/*.{ts,tsx}', + ], +}; diff --git a/x-pack/plugins/security_solution/public/hosts/jest.config.js b/x-pack/plugins/security_solution/public/hosts/jest.config.js new file mode 100644 index 00000000000000..b0ead04130b74e --- /dev/null +++ b/x-pack/plugins/security_solution/public/hosts/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/hosts'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/hosts', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/public/hosts/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/public/jest.config.js b/x-pack/plugins/security_solution/public/jest.config.js new file mode 100644 index 00000000000000..f2bde770370f44 --- /dev/null +++ b/x-pack/plugins/security_solution/public/jest.config.js @@ -0,0 +1,18 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../..', + /** all nested directories have their own Jest config file */ + testMatch: ['/x-pack/plugins/security_solution/public/*.test.{js,mjs,ts,tsx}'], + roots: ['/x-pack/plugins/security_solution/public'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/public/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/public/management/jest.config.js b/x-pack/plugins/security_solution/public/management/jest.config.js new file mode 100644 index 00000000000000..fdb6212ef6c816 --- /dev/null +++ b/x-pack/plugins/security_solution/public/management/jest.config.js @@ -0,0 +1,18 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/management'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/management', + coverageReporters: ['text', 'html'], + collectCoverageFrom: [ + '/x-pack/plugins/security_solution/public/management/**/*.{ts,tsx}', + ], +}; diff --git a/x-pack/plugins/security_solution/public/network/jest.config.js b/x-pack/plugins/security_solution/public/network/jest.config.js new file mode 100644 index 00000000000000..6059805c0652a9 --- /dev/null +++ b/x-pack/plugins/security_solution/public/network/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/network'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/network', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/public/network/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/public/overview/jest.config.js b/x-pack/plugins/security_solution/public/overview/jest.config.js new file mode 100644 index 00000000000000..673eece7a36fdb --- /dev/null +++ b/x-pack/plugins/security_solution/public/overview/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/overview'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/overview', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/public/overview/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/public/resolver/jest.config.js b/x-pack/plugins/security_solution/public/resolver/jest.config.js new file mode 100644 index 00000000000000..43e1202d9d8da4 --- /dev/null +++ b/x-pack/plugins/security_solution/public/resolver/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/resolver'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/resolver', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/public/resolver/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/jest.config.js b/x-pack/plugins/security_solution/public/timelines/jest.config.js similarity index 55% rename from x-pack/plugins/security_solution/jest.config.js rename to x-pack/plugins/security_solution/public/timelines/jest.config.js index 6cfcb65bb5d685..94434b9303d47f 100644 --- a/x-pack/plugins/security_solution/jest.config.js +++ b/x-pack/plugins/security_solution/public/timelines/jest.config.js @@ -7,11 +7,12 @@ module.exports = { preset: '@kbn/test', - rootDir: '../../..', - roots: ['/x-pack/plugins/security_solution'], - coverageDirectory: '/target/kibana-coverage/jest/x-pack/plugins/security_solution', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/timelines'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/timelines', coverageReporters: ['text', 'html'], collectCoverageFrom: [ - '/x-pack/plugins/security_solution/{common,public,server}/**/*.{ts,tsx}', + '/x-pack/plugins/security_solution/public/timelines/**/*.{ts,tsx}', ], }; diff --git a/x-pack/plugins/security_solution/public/transforms/jest.config.js b/x-pack/plugins/security_solution/public/transforms/jest.config.js new file mode 100644 index 00000000000000..30847fa39a8d89 --- /dev/null +++ b/x-pack/plugins/security_solution/public/transforms/jest.config.js @@ -0,0 +1,18 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/public/transforms'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/transforms', + coverageReporters: ['text', 'html'], + collectCoverageFrom: [ + '/x-pack/plugins/security_solution/public/transforms/**/*.{ts,tsx}', + ], +}; diff --git a/x-pack/plugins/security_solution/server/client/jest.config.js b/x-pack/plugins/security_solution/server/client/jest.config.js new file mode 100644 index 00000000000000..ba3dd88f83303d --- /dev/null +++ b/x-pack/plugins/security_solution/server/client/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/server/client'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/client', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/server/client/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/server/endpoint/jest.config.js b/x-pack/plugins/security_solution/server/endpoint/jest.config.js new file mode 100644 index 00000000000000..4fed1c5e7ac154 --- /dev/null +++ b/x-pack/plugins/security_solution/server/endpoint/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/server/endpoint'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/endpoint', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/server/endpoint/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/server/fleet_integration/jest.config.js b/x-pack/plugins/security_solution/server/fleet_integration/jest.config.js new file mode 100644 index 00000000000000..81625081c40c6e --- /dev/null +++ b/x-pack/plugins/security_solution/server/fleet_integration/jest.config.js @@ -0,0 +1,18 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/server/fleet_integration'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/fleet_integration', + coverageReporters: ['text', 'html'], + collectCoverageFrom: [ + '/x-pack/plugins/security_solution/server/fleet_integration/**/*.{ts,tsx}', + ], +}; diff --git a/x-pack/plugins/security_solution/server/jest.config.js b/x-pack/plugins/security_solution/server/jest.config.js new file mode 100644 index 00000000000000..2fc23670388b99 --- /dev/null +++ b/x-pack/plugins/security_solution/server/jest.config.js @@ -0,0 +1,18 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../..', + /** all nested directories have their own Jest config file */ + testMatch: ['/x-pack/plugins/security_solution/server/*.test.{js,mjs,ts,tsx}'], + roots: ['/x-pack/plugins/security_solution/server'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/server/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/server/lib/jest.config.js b/x-pack/plugins/security_solution/server/lib/jest.config.js new file mode 100644 index 00000000000000..4c4c7d8d4a6b7d --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/server/lib'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/lib', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/server/lib/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/server/search_strategy/jest.config.js b/x-pack/plugins/security_solution/server/search_strategy/jest.config.js new file mode 100644 index 00000000000000..93b9ddbf7a27d6 --- /dev/null +++ b/x-pack/plugins/security_solution/server/search_strategy/jest.config.js @@ -0,0 +1,18 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/server/search_strategy'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/search_strategy', + coverageReporters: ['text', 'html'], + collectCoverageFrom: [ + '/x-pack/plugins/security_solution/server/search_strategy/**/*.{ts,tsx}', + ], +}; diff --git a/x-pack/plugins/security_solution/server/usage/jest.config.js b/x-pack/plugins/security_solution/server/usage/jest.config.js new file mode 100644 index 00000000000000..82386fea363fe0 --- /dev/null +++ b/x-pack/plugins/security_solution/server/usage/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/server/usage'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/usage', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/server/usage/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/security_solution/server/utils/jest.config.js b/x-pack/plugins/security_solution/server/utils/jest.config.js new file mode 100644 index 00000000000000..d3a2e138b789d9 --- /dev/null +++ b/x-pack/plugins/security_solution/server/utils/jest.config.js @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/x-pack/plugins/security_solution/server/utils'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/utils', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/security_solution/server/utils/**/*.{ts,tsx}'], +}; From 5f45997e82887e85acaebbe0b3e61ab9790ac939 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 9 Nov 2021 14:17:23 -0800 Subject: [PATCH 2/2] Skip failing test Signed-off-by: Tyler Smalley --- packages/kbn-cli-dev-mode/src/dev_server.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-cli-dev-mode/src/dev_server.test.ts b/packages/kbn-cli-dev-mode/src/dev_server.test.ts index 5e386e3de59726..7c661bd4847788 100644 --- a/packages/kbn-cli-dev-mode/src/dev_server.test.ts +++ b/packages/kbn-cli-dev-mode/src/dev_server.test.ts @@ -117,7 +117,7 @@ afterEach(() => { subscriptions.length = 0; }); -describe('#run$', () => { +describe.skip('#run$', () => { it('starts the dev server with the right options', () => { run(new DevServer(defaultOptions)).unsubscribe();