Skip to content

Allow configuring using array of patterns to match test names #8683

Closed
@AELSchauer

Description

@AELSchauer

🚀 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

  1. A permanent config option for testNameMatch and/or testNameRegex
  2. When utilizing testNameMatch and/or testNameRegex in the config file, an array of patterns may be specified.
  3. Like their path counterparts, testNameMatch supports glob patterns with micromatch, and testNameRegex supports regex patterns.
  4. Like their path counterparts, if bothtestNameMatch and testNameRegex 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\).*']
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions