Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTaskFullName() includes leading space, breaking testNamePattern #4045

Closed
6 tasks done
jaswrks opened this issue Aug 29, 2023 · 2 comments · Fixed by #4071 or #5435
Closed
6 tasks done

getTaskFullName() includes leading space, breaking testNamePattern #4045

jaswrks opened this issue Aug 29, 2023 · 2 comments · Fixed by #4071 or #5435
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority)

Comments

@jaswrks
Copy link

jaswrks commented Aug 29, 2023

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

@jaswrks
Copy link
Author

jaswrks commented Aug 29, 2023

Problematic line:

return `${task.suite ? `${getTaskFullName(task.suite)} ` : ''}${task.name}`

@sheremet-va
Copy link
Member

@segrey would you be ok with reintroducing #4071? Is Webstorrm ready for this change?

@sheremet-va sheremet-va added p2-edge-case Bug, but has workaround or limited in scope (priority) and removed bug pr welcome labels Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority)
Projects
Archived in project
2 participants