Skip to content

getTaskFullName() includes leading space, breaking testNamePattern #4045

@jaswrks

Description

@jaswrks

Describe the bug

The getTaskFullName() function injects a leading space when it detects a suite. However, a suite itself includes a suite property with an empty name, and therefore it runs twice on a suite. The end result is that every test inside a suite ends up with a full task name that has a leading single-space indentation, which breaks regular expression patterns like this:

--testNamePattern '^my-suite-prefix:'

I did finally get it working, by using this to account for the leading space.

--testNamePattern '^\s*my-suite-prefix:'

Reproduction

--testNamePattern '^my-suite-prefix:'

Will not match a suite like this:

describe('my-suite-prefix:', () => { ... });

System Info

Vitest 0.34.3

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    No type

    Projects

    Status

    P2 - 2

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions