-
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
Merged
+6
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nickofthyme
added
release_note:skip
Skip the PR/issue when compiling release notes
backport:all-open
Backport to all branches that could still receive a release
labels
Jan 10, 2025
💚 Build Succeeded
Metrics [docs]
|
jbudz
approved these changes
Jan 10, 2025
Starting backport for target branches: 7.17, 8.16, 8.17, 8.x |
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Jan 10, 2025
…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)
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Jan 10, 2025
…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)
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Jan 10, 2025
…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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport:all-open
Backport to all branches that could still receive a release
release_note:skip
Skip the PR/issue when compiling release notes
v9.0.0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.