Closed tomspeak closed 2 years ago
Hi @tomspeak ,
I tried to reproduce this but it works for me.
test("i have a-in my name", () => {...})
can be run properly, the -
needs to be escaped. Which version of Jest are you using?
hey @David-Kunz
Jest: v26.6.3 Node: v14.18.3 NVIM v0.8.0-dev+406-g502f03fc0 OS: Mac OS
I can reproduce it 100% of the time, as soon as I remove the -
the test it is looking for goes from
with tests matching "i have a\\-in my name".
to
with tests matching "i have ain my name".
And it works.
Just want to note that the jest does run correctly, but it skips every single test in the file because it cannot find the test name.
As I mentioned in my other issue, I have a custom setup, could that be interfering?
MY_JESTER = require("jester")
MY_JESTER.setup({})
vim.api.nvim_set_keymap(
"n",
"<leader>t",
"<cmd>lua MY_JESTER.run({ cmd = 'NODE_PATH=. react-scripts test --testNamePattern=\\'$result\\' --testPathPattern=$file' })<CR>"
,
{ noremap = true }
)
vim.api.nvim_set_keymap(
"n",
"<leader>T",
"<cmd>lua require'jester'.run_file({ cmd = 'NODE_PATH=. react-scripts test --testPathPattern=$file' })<CR>",
{ noremap = true }
)
run_file
works fine with or without the -
in a test name in that file, I only have issues running run
.
@tomspeak, Yes, probably your custom setup is interfering.
What is the exact command which is run by Jest?
Closing this issue, if you still experience a problem with it, please come back to me.
Hi @David-Kunz, I'm experiencing the same issue. I can share what is being run on my case:
npx sfdx-lwc-jest -- -t '^c\\-api\\-data\\-fetcher does not display success or error messages when loading$' /home/fede/P
rogramming/Salesforce/one\\-customer\\-care\\-sfdc/force\\-app/main/default/lwc/apiDataFetcher/__tests__/apiDataFetcher\\.test\\.js
Please note the npx sfdx-lwc-jest --
is a wrapper around jest, but works fine if the dashes are not double escaped:
npx sfdx-lwc-jest -- -t '^c-api-data-fetcher does not display' force-app/main/default/lwc/apiDataFetcher/__tests__/apiDataFetcher.test.js
works fine (I dropped the $, but it just ends up running multiple tests)
This is my config:
return {
'David-Kunz/jester',
config = function()
require('jester').setup {
cmd = "npx sfdx-lwc-jest -- -t '$result' $file",
prepend = { 'describe' },
terminal_cmd = ":ToggleTerm direction=float"
}
end
}
I'm also running this on zsh
, in case that changes anything.
Let me know what else I can get for you.
Edit: Given OP was running this on MacOS (which I think ships zsh
by default) could this be $result
not being escaped properly for zsh
?
Edit 2: Nope, just reproduced it in bash
. Same double escaping of dashes.
Edit 3: Replicated in bash
and zsh
. Both in and out of tmux
, and both in alacritty
and gnome-terminal
does not work. It forwards it to jest like
i have a\\-in my name
works