[kbn-test] Jest run script should use testPathPattern to lookup config (#206341)

Adds logic to support the jest vscode extension by reading the
`--testPathPattern` arg for the purpose of config lookup. This enables
running tests easily in the vscode jest extension.
This commit is contained in:
Nick Partridge 2025-01-10 17:27:05 -06:00 committed by GitHub
parent cebd201981
commit 481b8037d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,6 +79,11 @@ export function runJest(configName = 'jest.config.js') {
if (!argv.config) {
testFiles = argv._.map((p) => resolve(cwd, p.toString()));
if (argv.testPathPattern) {
testFiles.push(argv.testPathPattern);
}
const commonTestFiles = commonBasePath(testFiles);
const testFilesProvided = testFiles.length > 0;
@ -123,7 +128,7 @@ export function runJest(configName = 'jest.config.js') {
);
} else {
log.error(
`we no longer ship a root config file so you either need to pass a path to a test file, a folder where tests can be found, or a --config argument pointing to one of the many ${configName} files in the repository`
`we no longer ship a root config file so you either need to pass a path to a test file, a folder where tests can be found, a --testPathPattern argument pointing to a file/directory or a --config argument pointing to one of the many ${configName} files in the repository`
);
}