Skip to content

Commit

Permalink
[kbn-test] Jest run script should use testPathPattern to lookup con…
Browse files Browse the repository at this point in the history
…fig (#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.
  • Loading branch information
nickofthyme authored Jan 10, 2025
1 parent cebd201 commit 481b803
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/kbn-test/src/jest/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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`
);
}

Expand Down

0 comments on commit 481b803

Please sign in to comment.