-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[kbn-test] Jest run script should use testPathPattern
to lookup config
#206341
Conversation
💚 Build Succeeded
Metrics [docs]
|
Starting backport for target branches: 7.17, 8.16, 8.17, 8.x https://github.com/elastic/kibana/actions/runs/12718816148 |
…fig (elastic#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. (cherry picked from commit 481b803)
…fig (elastic#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. (cherry picked from commit 481b803)
…fig (elastic#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. (cherry picked from commit 481b803)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
…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]>
…60; to lookup config (#206341) (#206354) # Backport This will backport the following commits from `main` to `8.16`: - [[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]>
…60; to lookup config (#206341) (#206355) # Backport This will backport the following commits from `main` to `8.17`: - [[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]>
Starting backport for target branches: 8.16, 8.17, 8.x https://github.com/elastic/kibana/actions/runs/12719812271 |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
Summary
TLDR; 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.Currently the
yarn test:jest
command, requires one of the following:--config
argument pointing to one of the manyjest.config.js
filesThe jest vscode extension does not easily support this behavior as it expects a static command to run all tests.
One option people have used is
virtualfolders
but this requires enumerating all possible configs. See doc.This could be autogenerate and
@managed
options in.vscode/setting
but this is more complicated to achieve at the moment.Without using
virtualFolders
the best option is to use thejestcommandline
. But this option does not allow parameterizing the command like we can with the debuglaunch.json
config (e.g."${jest.testNamePattern}"
).The
jestcommandline
does however pass a few additional argument as shown below...Most importantly the
--testPathPattern
argument. This is passed whenever the extension is ran against a directory, file or specific test. The file name is passed as unnamed argument when run on save of a file. But the currentyarn test:jest
command expects this as an additional unnamed argument. This PR now treats thetestPathPattern
as a file or directory to find the config.Warning
This works for most cases with the most notable exception being if you were to run a directory that contained multiple
jest.config.ts
files. This would error just the same as calling something like...Or running this from the vscode jest extension like this...
This would result in multiple configs which will not work. I think this is not a very common use case.
If we did want to address this case I think it could be solved with
virtualFolders
to run files grouped by their respective configs.