From bd8b4e3ba218b6fc69c35190c1603a0d99deefdc Mon Sep 17 00:00:00 2001 From: Rafed Ramzi <68276604+rafedramzi@users.noreply.github.com> Date: Tue, 25 Oct 2022 16:31:05 +0700 Subject: [PATCH] fix(cli): set inputNamePattern to RegExp source instead of string (#2201) 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/ --- packages/vitest/src/node/stdin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vitest/src/node/stdin.ts b/packages/vitest/src/node/stdin.ts index a79bce614924..b4bd5e3d7d5f 100644 --- a/packages/vitest/src/node/stdin.ts +++ b/packages/vitest/src/node/stdin.ts @@ -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()