vscode-jest-runner icon indicating copy to clipboard operation
vscode-jest-runner copied to clipboard

Debugging a test with describe.each in a zsh terminal fails

Open electricmonk opened this issue 2 years ago • 4 comments

When I try to debug a test using the debug button, on a macOS machine running zsh, the script generated by the extension contains the test name pattern -t \(.\*?\), which is parsed by zsh as a glob wildcard so nothing runs, I get the error

zsh: no matches found: (.*?)

Wrapping with quotation marks solves this.

electricmonk avatar Jul 15 '22 07:07 electricmonk

didnt manage to make the escaping correct for all different terminals yet. thank for your report.

firsttris avatar Oct 14 '22 08:10 firsttris

When you run a test with a regex in the name it single quotes the string and it works with zsh. When you debug a test with a regex in the name, the command line has \ quoting for the name and the causes zsh to barf (unless you have unsetopt nomatch)

it(`has a test called ${x}`, () => {
  expect(true).toBeTruthy();
});

Run ...

 node 'node_modules/.bin/jest' '/Users/mtoy/test/stupid.spec.ts' -t 'has a test called (.*?)'

Debug ...

/usr/bin/env ... (stuff) ... /Users/mtoy/test/stupid.spec.ts -t has\ a\ test\ called\ \(.\*?\) --runInBand 
zsh: no matches found: has a test called (.*

zsh wants that question mark to be quoted also ... or for you to run with unsetopt nomatch (which I have in my .zshrc for now)

mtoy-googly-moogly avatar Nov 01 '22 17:11 mtoy-googly-moogly

I have the same error, also on macOS with zsh.

Drarig29 avatar Nov 14 '22 17:11 Drarig29