Closed
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
testNameMatch
and/ortestNameRegex
- When utilizing
testNameMatch
and/ortestNameRegex
in the config file, an array of patterns may be specified. - Like their path counterparts,
testNameMatch
supports glob patterns with micromatch, andtestNameRegex
supports regex patterns. - Like their path counterparts, if both
testNameMatch
andtestNameRegex
are 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\).*']
...