Closed necjosh closed 5 days ago
I had no idea that ^
is used as an escape character in CMD....
Anyway, it seems that there is no need to use an escape character in the testNamePattern, I suppose because it's in quotes?
CMD does not interpret ^
as an escape character in this portion of the command, so it's passed on as an actual part of the regexp.
I confirmed this by running a few commands in CMD.
#command:
Echo THIS & THAT
#output:
THIS
'THAT' is not recognized as an internal or external command,
operable program or batch file.
#command:
Echo THIS ^& THAT
#output:
THIS & THAT
#command:
Echo "THIS & THAT"
#output:
"THIS & THAT"
#command:
Echo "THIS ^& THAT"
#output:
"THIS ^& THAT"
As you can see in the last example, the caret does not act as an escape character in this case.
yes, this looks like a bug... thanks for raising the issue, I will take a look.
@necjosh, I think I have a fix. Do you mind confirming if the new build fixes your issue: vscode-jest-6.3.0.vsix.zip
Describe the bug Instead of a backslash, a caret is used to escape special characters in the
testNamePattern
when running an individual test through the UI. This causes the test to be skipped.What I also find curious is that the
testNamePattern
is included in the command at all. I'm running the entire test file, I don't understand why it's including it since thetestPathPattern
already narrows it down to the file exclusively.Spawn command:
[Extension Host] spawning process with command=npm test -- --testLocationInResults --json --useStderr --outputFile [omitted] --testNamePattern "foo ^> bar$" --no-coverage --reporters default --reporters "[omitted]" --colors --watchAll=false --testPathPattern "[omitted]\\src\\App\.test\.js"
I added more special characters to see which ones are affected:
! ^ & < >
are affected.To Reproduce Sample repo
Steps to reproduce the behavior:
Expected behavior Backslashes are used to escape special characters in the testNamePattern.
Environment (please complete the following information):
node -v
: 21.6.1, also tested on LTS 20.17.0npm -v
oryarn --version
: npm 10.2.4Prerequisite
npm run test
,npx jest