-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Allow configuring using an array of testRegex
#7180
Comments
@rickhanlonii @thymikee we just discussed config overhaul as it's quite the hot mess, and the mess that is regex vs glob, separate ignore fields etc should definitely be on the chopping block. A single issue going through all config options (and CLI options) might make sense, although I guess file matching is big enough to be discussed on its own (e.g. in this issue). So to be on topic; for file matching, of the top of my head, this is my suggestion: |
Using globs exclusively is definitely preferable imho. I was going for a quick fix here; but I'm definitely in favor of standardization if breaking changes are on the table. |
Short term I think it makes sense for testRegex to accept either a string or array 👍 |
If you all are amenable to that solution for now I can take a crack at it, it doesn't seem like it would be a big change. |
Doing |
All you @jamietre! |
I have this working, except that in https://github.com/facebook/jest/blob/master/packages/jest-config/src/normalize.js line 348, we call There's no obvious way to make this work without adding features to the validator. I can think of lots of ways to make the validator handle multiple types (and indeed implemented one), but there are consequences beyond just accepting more than one option. For example, when validation fails, it shows an example based on the Other options I can think of are just skip validation for |
Mind pushing what you have to a branch so we cab play with it? @thymikee thoughts on the validation? |
Here's the branch on my fork; lmk if I should make a pull request. (ignore launch.json changes - the default settings resulting in formatting being wrong every time I save!) https://github.com/jamietre/jest/commits/jamiet/multiple-test-regexes |
I think I like the "MultipleValidOptions" addition to |
OK, sounds good... I still need to fix up how validation errors involving multiple valid options are reported, will do that & send it on. |
Linking to #7185. This is something we'll probably want to include there |
## Summary Split from #7194 Prerequisite to resolving #7180 This PR provides a syntax for `jest-validate` to accept more than one example for a single config value, which can be of different types. This allows overloading config options to accept multiple types. ## Test plan - existing unit tests pass (except as expected where internal config changed types) - added unit tests to cover new valid and error conditions
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Creating dynamic configurations to include or exclude specific things is difficult because of inconsistency in how config allows specifying inclusions and exclusions.
testRegex
allows only a single regexptestMatch
allows an array of globstestPathIgnorePatterns
allows an array of regexpsSo there's no format (regex or glob) that can be used to build an array that works both for including and excluding.
It would be very convenient if either there were an analog to
testMatch
for ignoring (an array of globs), or it were permissible to provide an array of regexps instead of only a single one fortestRegex
.I think the easiest solution to implement would be simply accepting an array or a single regexp for
testRegex
. Additionally, the regexp array convention is much widely used already (coveragePathIgnorePatterns
,modulePathIgnorePatterns
,transformPathIgnorePatterns
,watchPathIgnorePatterns
,testPathIgnorePatterns
). Alternatively, a new config optiontestPathPatterns
could be introduced that only accepts an array, for consistency with all the ignore options, but it seems redundant.I'd like to take a shot at coding it, but wanted to vet the feature idea before doing any work.
Motivation
Motivation is creating simple configuration that can be used to run buckets of tests that are dynamically specified by pattern matching. For example, I would like to be able to specify patterns that match slow tests, and be able to produce dynamic config that can both exclude only slow tests, or run only slow tests.
Example
jest.config.js
Pitch
Why does this feature belong in the Jest core platform?
It would be great for creating optimized configurations in large test environments. It makes the way file matching patterns are specified in configuration more consistent as well.
The text was updated successfully, but these errors were encountered: