From ff9021927db4fd785cd9a63fd4292f39b6247920 Mon Sep 17 00:00:00 2001 From: Rafed Ramzi Date: Mon, 24 Oct 2022 12:12:45 +0700 Subject: [PATCH] fix(cli): set inputNamePattern to RegExp source instead of string 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()