Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
loqusion opened this issue Nov 1, 2022 · 7 comments · May be fixed by #117
Open

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

loqusion opened this issue Nov 1, 2022 · 7 comments · May be fixed by #117

Comments

@loqusion
Copy link

loqusion commented Nov 1, 2022

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
Copy link
Author

loqusion commented Nov 1, 2022

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
Copy link
Contributor

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 added a commit to loqusion/neotest-jest that referenced this issue Apr 5, 2024
loqusion added a commit to loqusion/neotest-jest that referenced this issue Apr 5, 2024
@loqusion loqusion linked a pull request Apr 5, 2024 that will close this issue
@loqusion
Copy link
Author

loqusion commented Apr 5, 2024

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

@loqusion
Copy link
Author

loqusion commented Apr 5, 2024

@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`".

@loqusion loqusion changed the title Tests with backticks are either ignored or always produce an error Tests names with backticks are either ignored or always produce an error Apr 5, 2024
@conermurphy
Copy link
Contributor

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
Copy link
Author

loqusion commented Apr 6, 2024

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
Copy link
Contributor

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? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants