Skip to content
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 array of regexp strings for testRegex #7194

Closed
wants to merge 2 commits into from

Conversation

jamietre
Copy link
Contributor

Summary

Resolves #7180

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 regexp
  • testMatch allows an array of globs
  • testPathIgnorePatterns allows an array of regexps

So there's no format (regex or glob) that can be used to build an array that works both for including and excluding.

This PR allows testRegex to accept an array of regex strings as well as a string, resolving this problem.

Because this is the first configuration option that's overloaded with more than one valid type, jest-validation has also been enhanced with syntax that allows specifying more than one valid example in configuration.

Test plan

  • existing unit tests pass (except as expected where internal config changed types)
  • added unit tests to cover valid and error conditions

@jamietre jamietre requested a review from orta as a code owner October 17, 2018 19:05
@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@SimenB
Copy link
Member

SimenB commented Oct 18, 2018

Mind opening up a separate PR with the jest-validate changes? I think it makes sense as a separate commit in the tree. Please include an update to its readme as well 🙂

@jamietre
Copy link
Contributor Author

I think I need to make a new PR to have it depend on the jest-validate one #7207 that I just created, so closing this.

@jamietre jamietre closed this Oct 18, 2018
@jamietre
Copy link
Contributor Author

Hmm. Well, github doesn't seem to treat the new one any differently though I branched it from the #7207. I guess I just don't know how to make a dependent pull request... anyway, this has been replaced with #7209

SimenB pushed a commit that referenced this pull request Oct 18, 2018
## 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
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow configuring using an array of testRegex
3 participants