Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jest] Support meta project configs #118122

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/kbn-test/src/jest/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ declare global {

export function runJest(configName = 'jest.config.js') {
const argv = buildArgv(process.argv);
const devConfigName = 'jest.config.dev.js';

const log = new ToolingLog({
level: argv.verbose ? 'verbose' : 'info',
Expand All @@ -67,18 +68,25 @@ export function runJest(configName = 'jest.config.js') {
log.verbose('commonTestFiles:', commonTestFiles);

let configPath;
let devConfigPath;

// sets the working directory to the cwd or the common
// base directory of the provided test files
let wd = testFilesProvided ? commonTestFiles : cwd;

devConfigPath = resolve(wd, devConfigName);
configPath = resolve(wd, configName);

while (!existsSync(configPath)) {
while (!existsSync(configPath) && !existsSync(devConfigPath)) {
wd = resolve(wd, '..');
devConfigPath = resolve(wd, devConfigName);
configPath = resolve(wd, configName);
}

if (existsSync(devConfigPath)) {
configPath = devConfigPath;
}

log.verbose(`no config provided, found ${configPath}`);
process.argv.push('--config', configPath);

Expand Down
17 changes: 17 additions & 0 deletions x-pack/plugins/security_solution/jest.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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: '../../../',
projects: [
'<rootDir>/x-pack/plugins/security_solution/*/jest.config.js',

'<rootDir>/x-pack/plugins/security_solution/server/*/jest.config.js',
'<rootDir>/x-pack/plugins/security_solution/public/*/jest.config.js',
],
};