Skip to content

Wrong test path pattern from CLI args #5037

@seanpoulter

Description

@seanpoulter

Do you want to request a feature or report a bug?
Bug

What is the current behavior?

  1. When passing more than one --testPathPattern as command line arguments the test path pattern is wrong. The arg is typed as a string but multiple values mean the Array<string> is magically joined with , when the pattern is created by new RegExp(pattern, 'i').

    You can quickly see the pattern in the console by entering two paths that don't match:

    > jest aa bb
    ...
    Pattern: aa|bb
    
    > jest --testPathPattern=aa --testPathPattern=bb
    ...
    Pattern: aa,bb
    
  2. When passing a --testPathPattern and an unnamed argument, they're not joined together. Again from the console:

    > jest aa --testPathPattern=bb
    ...
    Pattern: bb
    

What is the expected behavior?
Looks like we should:

  • Update the arg type to be an Array<string>
  • Join multiple testPathPattern args with |
  • Join any testPathPattern args with the unnamed args

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

Jest: 21.2.1
Code: Looking at the head of the master branch
Found while adding tests for #3793

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions