Skip to content

Commit

Permalink
fix(runner): another way to allow leading space in testNamePattern (v…
Browse files Browse the repository at this point in the history
  • Loading branch information
segrey committed Sep 19, 2023
1 parent a47d52e commit c93f74b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/runner/src/utils/collect.ts
Expand Up @@ -27,8 +27,14 @@ export function interpretTaskModes(suite: Suite, namePattern?: string | RegExp,
}
}
if (t.type === 'test') {
if (namePattern && !getTaskFullName(t).match(namePattern))
t.mode = 'skip'
if (namePattern) {
const taskFullName = getTaskFullName(t)
// Match also the task full name with a leading space to be backward-compatible with tools like
// IntelliJ/WebStorm. Previous Vitest versions (<= 0.34.3) had the task full name starting
// with a space, and the tools passed `testNamePattern` matching it.
if (!(taskFullName.match(namePattern) || ` ${taskFullName}`.match(namePattern)))
t.mode = 'skip'
}
}
else if (t.type === 'suite') {
if (t.mode === 'skip')
Expand Down

0 comments on commit c93f74b

Please sign in to comment.