[jest] Support meta project configs (#118122)
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
f4b61d01be
commit
ff86a51a01
|
@ -44,6 +44,7 @@ declare global {
|
||||||
|
|
||||||
export function runJest(configName = 'jest.config.js') {
|
export function runJest(configName = 'jest.config.js') {
|
||||||
const argv = buildArgv(process.argv);
|
const argv = buildArgv(process.argv);
|
||||||
|
const devConfigName = 'jest.config.dev.js';
|
||||||
|
|
||||||
const log = new ToolingLog({
|
const log = new ToolingLog({
|
||||||
level: argv.verbose ? 'verbose' : 'info',
|
level: argv.verbose ? 'verbose' : 'info',
|
||||||
|
@ -67,18 +68,25 @@ export function runJest(configName = 'jest.config.js') {
|
||||||
log.verbose('commonTestFiles:', commonTestFiles);
|
log.verbose('commonTestFiles:', commonTestFiles);
|
||||||
|
|
||||||
let configPath;
|
let configPath;
|
||||||
|
let devConfigPath;
|
||||||
|
|
||||||
// sets the working directory to the cwd or the common
|
// sets the working directory to the cwd or the common
|
||||||
// base directory of the provided test files
|
// base directory of the provided test files
|
||||||
let wd = testFilesProvided ? commonTestFiles : cwd;
|
let wd = testFilesProvided ? commonTestFiles : cwd;
|
||||||
|
|
||||||
|
devConfigPath = resolve(wd, devConfigName);
|
||||||
configPath = resolve(wd, configName);
|
configPath = resolve(wd, configName);
|
||||||
|
|
||||||
while (!existsSync(configPath)) {
|
while (!existsSync(configPath) && !existsSync(devConfigPath)) {
|
||||||
wd = resolve(wd, '..');
|
wd = resolve(wd, '..');
|
||||||
|
devConfigPath = resolve(wd, devConfigName);
|
||||||
configPath = resolve(wd, configName);
|
configPath = resolve(wd, configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (existsSync(devConfigPath)) {
|
||||||
|
configPath = devConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
log.verbose(`no config provided, found ${configPath}`);
|
log.verbose(`no config provided, found ${configPath}`);
|
||||||
process.argv.push('--config', configPath);
|
process.argv.push('--config', configPath);
|
||||||
|
|
||||||
|
|
17
x-pack/plugins/security_solution/jest.config.dev.js
Normal file
17
x-pack/plugins/security_solution/jest.config.dev.js
Normal file
|
@ -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',
|
||||||
|
],
|
||||||
|
};
|
Loading…
Reference in a new issue