diff --git a/src/jestRunner.ts b/src/jestRunner.ts index 776b53c..b0c2511 100644 --- a/src/jestRunner.ts +++ b/src/jestRunner.ts @@ -6,6 +6,7 @@ import { escapeRegExp, escapeRegExpForPath, escapeSingleQuotes, + escapeTestName, findFullTestName, normalizePath, pushMany, @@ -59,7 +60,7 @@ export class JestRunner { await editor.document.save(); const filePath = editor.document.fileName; - const testName = currentTestName || this.findCurrentTestName(editor); + const testName = escapeTestName(currentTestName || this.findCurrentTestName(editor)); const command = this.buildJestCommand(filePath, testName, options); this.previousCommand = command; diff --git a/src/util.ts b/src/util.ts index 6470ce5..9b7a824 100644 --- a/src/util.ts +++ b/src/util.ts @@ -57,6 +57,10 @@ export function escapeSingleQuotes(s: string): string { return isWindows() ? s : s.replace(/'/g, "'\\''"); } +export function escapeTestName(s: string): string { + return isWindows() ? s.replace(/"/g, "'") : s.replace(/'/g, '"'); +} + export function quote(s: string): string { const q = isWindows() ? '"' : `'`; return [q, s, q].join('');