nvim-neotest / neotest-jest

MIT License
121 stars 80 forks source link

Tests names with backticks are either ignored or always produce an error #46

Open loqusion opened 2 years ago

loqusion commented 2 years ago

When there are two backticks in a test name, the test is ignored. When there is only one, the following error message is produced:

sh: -c: line 0: unexpected EOF while looking for matching ``'
sh: -c: line 1: syntax error: unexpected end of file

It seems that backticks are not properly escaped before being passed to the jest command, which causes them to be interpreted by the shell as command substitution instead of literal characters.

loqusion commented 2 years ago

Looking at the generated command from the Neotest output, it looks like the entire --testNamePattern argument is surrounded by double quotes. Double quotes are interpreted distinctly by the shell in that they allow for certain substitution, such as variable substitution and command output substitution. The single quotes after the = are just interpreted as literal characters, so the text they enclose is still considered surrounded by double quotes.

jest "--no-coverage" "--testLocationInResults" "--verbose" "--json" "--outputFile=/var/folders/7v/zybwdxz140n76nc
dnrtyy80m0000gn/T/nvim.12345/YzZrTS/78.json" "--testNamePattern='^request\\(\\) sets request body directly with data option$'" "<filename>"
conermurphy commented 7 months ago

I might be wrong (please correct me if I am) but I believe this will be fixed by the PR (#112) which I raised for #47.

loqusion commented 7 months ago

This seems to have been fixed at some point — I made a PR (#117) with regression tests just to be sure.

loqusion commented 7 months ago

@conermurphy #112 seems to fix tests that use backticks instead of single- or double-quotes for a JavaScript test string — e.g. `this is a test`. This issue is about backticks being present in the test string itself — e.g. "this is a `test`".

conermurphy commented 7 months ago

Ah that makes sense then @loqusion I did notice that the backticks in strings was working when I did #112 but they must have been fixed by the earlier PR before I did that one.

Also unrelated but I assume you have the tests running locally to make that PR? If so, would you be able to help with #114 at all? I'm keen to write tests when I contribute but can't get them running.

loqusion commented 7 months ago

I actually can't get the script to run either 😅 instead, I used the lazy.nvim dev field to use the local development version of neotest-jest to run the tests.

conermurphy commented 6 months ago

Ah okay so you just ran the jest tests in the repo using neotest itself? Might have to give that a shot. I wonder what's wrong with the script or what extra setup is needed? 🤔