From 0e0d1d3bc648d3d32d96dd20026a08e8656b0fdc Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 15 Feb 2022 18:06:13 -0800 Subject: [PATCH] Updates to Jest configuration (#125727) (cherry picked from commit e9d82d104b569e6b7ea72e2d2fe79121785aba6c) # Conflicts: # .buildkite/scripts/steps/code_coverage/jest.sh --- .buildkite/pipelines/es_snapshots/verify.yml | 1 + .buildkite/scripts/steps/test/jest.sh | 2 +- .../scripts/steps/test/jest_parallel.sh | 2 +- jest.config.integration.js | 27 ------------------- jest.config.js | 24 ----------------- .../src/jest/run_check_jest_configs_cli.ts | 4 +-- scripts/jest_integration.js | 2 +- 7 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 jest.config.integration.js delete mode 100644 jest.config.js diff --git a/.buildkite/pipelines/es_snapshots/verify.yml b/.buildkite/pipelines/es_snapshots/verify.yml index 7d700b1e0f489..f98626ef25c01 100755 --- a/.buildkite/pipelines/es_snapshots/verify.yml +++ b/.buildkite/pipelines/es_snapshots/verify.yml @@ -65,6 +65,7 @@ steps: - command: .buildkite/scripts/steps/test/jest_integration.sh label: 'Jest Integration Tests' + parallelism: 2 agents: queue: n2-4 timeout_in_minutes: 120 diff --git a/.buildkite/scripts/steps/test/jest.sh b/.buildkite/scripts/steps/test/jest.sh index d2d1ed10043d6..cbf8bce703cc6 100755 --- a/.buildkite/scripts/steps/test/jest.sh +++ b/.buildkite/scripts/steps/test/jest.sh @@ -10,4 +10,4 @@ is_test_execution_step echo '--- Jest' checks-reporter-with-killswitch "Jest Unit Tests $((BUILDKITE_PARALLEL_JOB+1))" \ - .buildkite/scripts/steps/test/jest_parallel.sh + .buildkite/scripts/steps/test/jest_parallel.sh jest.config.js diff --git a/.buildkite/scripts/steps/test/jest_parallel.sh b/.buildkite/scripts/steps/test/jest_parallel.sh index bc6184c74eb4a..948a441185fca 100755 --- a/.buildkite/scripts/steps/test/jest_parallel.sh +++ b/.buildkite/scripts/steps/test/jest_parallel.sh @@ -25,6 +25,6 @@ while read -r config; do ((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 ${1:-jest.config.js} -not -path "*/__fixtures__/*" | sort)" +done <<< "$(find src x-pack packages -name "$1" -not -path "*/__fixtures__/*" | sort)" exit $exitCode diff --git a/jest.config.integration.js b/jest.config.integration.js deleted file mode 100644 index a2ac498986c08..0000000000000 --- a/jest.config.integration.js +++ /dev/null @@ -1,27 +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. - */ - -const Fs = require('fs'); -const Path = require('path'); - -module.exports = { - preset: '@kbn/test/jest_integration', - rootDir: '.', - roots: [ - '/src', - '/packages', - ...Fs.readdirSync(Path.resolve(__dirname, 'x-pack')).flatMap((name) => { - // create roots for all x-pack/* dirs except for test - if (name !== 'test' && Fs.statSync(Path.resolve(__dirname, 'x-pack', name)).isDirectory()) { - return [`/x-pack/${name}`]; - } - - return []; - }), - ], -}; diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index ae07034c10781..0000000000000 --- a/jest.config.js +++ /dev/null @@ -1,24 +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: '.', - projects: [ - '/packages/*/jest.config.js', - '/src/*/jest.config.js', - '/src/plugins/*/jest.config.js', - '/src/plugins/chart_expressions/*/jest.config.js', - '/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-test/src/jest/run_check_jest_configs_cli.ts b/packages/kbn-test/src/jest/run_check_jest_configs_cli.ts index 6f7836e98d346..9522d9dafd6fd 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 @@ -10,7 +10,7 @@ import { writeFileSync } from 'fs'; import path from 'path'; import Mustache from 'mustache'; -import { run } from '@kbn/dev-utils'; +import { run, createFailError } from '@kbn/dev-utils'; import { REPO_ROOT } from '@kbn/utils'; import { JestConfigs, CONFIG_NAMES } from './configs'; @@ -72,7 +72,7 @@ export async function runCheckJestConfigsCli() { log.info('created %s', file); }); } else { - log.info( + throw createFailError( `Run 'node scripts/check_jest_configs --fix' to create the missing config files` ); } diff --git a/scripts/jest_integration.js b/scripts/jest_integration.js index 7332f368b31e2..9b4157eddaaf8 100755 --- a/scripts/jest_integration.js +++ b/scripts/jest_integration.js @@ -9,4 +9,4 @@ require('../src/setup_node_env/ensure_node_preserve_symlinks'); process.argv.push('--runInBand'); -require('@kbn/test').runJest('jest.config.integration.js'); +require('@kbn/test').runJest('jest.integration.config.js');