firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
264 stars 124 forks source link

Quote for both run and debug so it.each works #311

Open tlbdk opened 1 year ago

tlbdk commented 1 year ago
it.each([1,2,3,4])('should parse and generate %i and generate it again', id => {
...
})

Will generate the following command run:

node 'node_modules/.bin/jest' '/Users/tlb/git/connectedcars/ingester-tl-v2/src/lib/traffilog-parser/tools/monitor-csv-parser.test.ts' -t 'parser should parse and generate (.*?) and generate it again'

and the following command with debug:

... node node_modules/.bin/jest --testTimeout=100000000 --detectOpenHandles /Users/tlb/git/connectedcars/ingester-tl-v2/src/lib/traffilog-parser/tools/monitor-csv-parser.test.ts -t parser\ should\ parse\ and\ generate\ \(.\*?\)\ and\ generate\ it\ again --runInBand 

Resulting in:

zsh: no matches found: parser should parse and generate setting (.*?) and generate it again
firsttris commented 1 year ago

thanks for your contribution

fenixil commented 1 year ago

@firsttris hello, I've stumbled upon this issue too and glad to see that fix exists. Kindly advice if you plan to accept this PR.

domsleee commented 1 year ago

Some more info I found, ? is a wildcard character in zsh

~ > echo ?
zsh: no matches found: ?

In bash, it just prints ?.

So escaping provided by the vscode api does not escape the ? (and nor should it I think?): https://github.com/firsttris/vscode-jest-runner/blob/e3f7c76334c248ff426fd078a7634213b4106174/src/jestRunner.ts#L159

For powershell on windows, it is trying to match against literal double quotes, so it finds no matches (I don't think double quotes should be being used for powershell at all, but another problem).

Here is where powershell behaves differently to bash:

❯ echo """abc"""
"abc"

In summary, it seems fine to use single quotes on linux to solve this issue