Skip to content

Commit

Permalink
fix(cli): set inputNamePattern to RegExp source instead of string (#2201
Browse files Browse the repository at this point in the history
)

using RegExp.toString() returns a valid regex string (with / at the beginning and the end of the string), but when this value is reused as RegExp constructor, it tries to covert the string value in to regex, causing the those / to be escaped.
actual: /foo/ /\/foo\// /\/\/foo\/\//
expected: /bar/ /bar/ /bar/
  • Loading branch information
rafedramzi committed Oct 25, 2022
1 parent ed0c6d2 commit bd8b4e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vitest/src/node/stdin.ts
Expand Up @@ -69,7 +69,7 @@ export function registerConsoleShortcuts(ctx: Vitest) {
name: 'filter',
type: 'text',
message: 'Input test name pattern (RegExp)',
initial: String(ctx.config.testNamePattern || ''),
initial: ctx.config.testNamePattern?.source || '',
}])
await ctx.changeNamePattern(filter, undefined, 'change pattern')
on()
Expand Down

0 comments on commit bd8b4e3

Please sign in to comment.