Skip to content

Commit

Permalink
[8.x] [kbn-test] Jest run script should use `testPathPattern&#x6…
Browse files Browse the repository at this point in the history
…0; to lookup config (#206341) (#206356)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[kbn-test] Jest run script should use `testPathPattern` to
lookup config (#206341)](#206341)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-10T23:27:05Z","message":"[kbn-test]
Jest run script should use `testPathPattern` to lookup config
(#206341)\n\nAdds logic to support the jest vscode extension by reading
the\r\n`--testPathPattern` arg for the purpose of config lookup. This
enables\r\nrunning tests easily in the vscode jest
extension.","sha":"481b8037d609e2d7a994e7696e2fa23f7b44f2b9","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:all-open"],"title":"[kbn-test]
Jest run script should use `testPathPattern` to lookup
config","number":206341,"url":"https://github.com/elastic/kibana/pull/206341","mergeCommit":{"message":"[kbn-test]
Jest run script should use `testPathPattern` to lookup config
(#206341)\n\nAdds logic to support the jest vscode extension by reading
the\r\n`--testPathPattern` arg for the purpose of config lookup. This
enables\r\nrunning tests easily in the vscode jest
extension.","sha":"481b8037d609e2d7a994e7696e2fa23f7b44f2b9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/206341","number":206341,"mergeCommit":{"message":"[kbn-test]
Jest run script should use `testPathPattern` to lookup config
(#206341)\n\nAdds logic to support the jest vscode extension by reading
the\r\n`--testPathPattern` arg for the purpose of config lookup. This
enables\r\nrunning tests easily in the vscode jest
extension.","sha":"481b8037d609e2d7a994e7696e2fa23f7b44f2b9"}}]}]
BACKPORT-->

Co-authored-by: Nick Partridge <[email protected]>
  • Loading branch information
kibanamachine and nickofthyme authored Jan 11, 2025
1 parent 892f68d commit 8eec0e2
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 8eec0e2

Please sign in to comment.