-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
🚀 Feature Proposal
Currently, testNamePattern is only documented as a CLI feature, but it can be added to the config file. However, in the config file, it only allows for a single regex string. However, testRegex, testPath, etc. all utilize an array of patterns that may apply.
Requirements
- A permanent config option for
testNameMatchand/ortestNameRegex - When utilizing
testNameMatchand/ortestNameRegexin the config file, an array of patterns may be specified. - Like their path counterparts,
testNameMatchsupports glob patterns with micromatch, andtestNameRegexsupports regex patterns. - Like their path counterparts, if both
testNameMatchandtestNameRegexare implemented, both cannot be used at the same time.
Motivation
Utilizing "tags" in a test name is a helpful, dynamic way of organizing code. For example @mobile or ^desktop. Mocha documentation recommends this way of tagging code.
However, if wanting to apply multiple search queries, we must create a very complex, fragile regex query instead of being able to apply multiple queries. We can also not utilize glob queries, which are supported for paths.
Example
//jest.config.js
...
"testNameMatch":['*@desktop*' ,'*!@mobile*'],
"testNameRegex": ['.*@desktop.*', '.*\(w\/o JS\).*']
...
unzico and ryparker