Open codycjy opened 10 months ago
I had a similar issue where I had a supposedly good configuration, and a "no tests found" error.
My mistake was to not have ran :TSInstall <language_to_install>
after having installed nvim-treesitter.
I am having a hard time running Jest tests in a Typescript/Node.js project since two days ago, it was working perfectly until then. Neotest can identify the test files correctly as they show up in the summary view, but when trying to run them it always give me a "No tests found" message. I also have Treesitter installed for Typescript.
My coworker is having the same problem and we do not exchange configurations, we both use slightly modified versions of LazyVim.
I had not much time to dig into this, but I did some debugging and it looks like an issue when the Jest adapter tries to get the nearest test node to run. I am not sure exactly where the problem is so I am just posting this message here for visibility, in case someone else also have this issue.
@marcoskichel i have the same issue, started a couple of days ago. tests are detected correctly in :Neotest summary
, but they fail to run.
Neotest log contains warning
WARN | 2024-02-05T16:49:24Z+0200 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:161 | CHILD | Error in remote call ...im/0.9.5/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 494 for language typescript
stack traceback:
[C]: in function '_ts_parse_query'
...im/0.9.5/share/nvim/runtime/lua/vim/treesitter/query.lua:259: in function 'parse_query'
...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:104: in function 'normalise_query'
...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:161: in function 'parse_positions_from_string'
...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'func'
...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:153: in function <...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:152>
[C]: in function 'xpcall'
...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:152: in function <...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:151>
looks like Typescript treesitter has parsing issues
there's specific Typescript issue in neotest-jest
, is this one still relevant?
Here to confirm that on version v0.9.2
of nvim-treesitter
:
neotest
cannot find tests regardless of adapter (tried neotest-python
, neotest-jest
)lua require("neotest").run.run()
(the bigger the project, the longer the lag)
lua require("neotest").run.run()
again, it runs immediately but returns "No tests found"This is all fixed by reverting to v0.9.1
of nvim-treesitter
, indicating that there's a compatibility bug between that library and neotest
.
After upgrading neovim to 0.9.5(latest stable), test cases back to normal. Thank you @fnune
@codycjy I upgraded to Neovim 0.9.5
but Neotest still can't find tests if nvim-treesitter
is at v0.9.2
. Downgrading to v0.9.1
still works. IMO reopen, or I can open a different bug for the version incompatibility.
@fnune Am I correct in saying that's only for typescript? Everything is working well for me with python and lua
It's for all adapters (at least for me). There may be more things involved, but downgrading to v0.9.1
definitely helps.
Ah OK, could you paste the output of the logs at debug level?
Update: you were right @rcarriga it's only TypeScript. It turns out my Python test discovery was failing because my project also contains TypeScript. When I removed the neotest-jest
adapter from my project config, Python test discovery started working again.
Suggestion: cover against failures in test discovery from one adapter so that the other adapter still works? Also, the discovery failure was invisible to me as a user. The :Neotest summary
window showed that the nodetest-jest
adapter had found the directory structure of my project and correctly identified the test files but no tests within each test file. Maybe show an error message there?
Here are some logs from my TypeScript problem:
Neovim version: 0.9.5
$ nvim --version
NVIM v0.9.5
Neotest version: https://github.com/nvim-neotest/neotest/commits/f6048f32be831907fb15018af2688ff6633704fc
Treesitter version: https://github.com/nvim-treesitter/nvim-treesitter/commits/17d68ac13c902f55253b7facb47df4c0ae532575
(newer than 0.9.2
)
Behavior when trying to run a test (2nd try; 1st try does not return any output):
Logs on the 1st try (TSX):
WARN | 2024-02-17T13:50:28Z+0100 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:164 | CHILD | Error in remote call ...ed-0.9.5/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 494 for language tsx
stack traceback:
[C]: in function '_ts_parse_query'
...ed-0.9.5/share/nvim/runtime/lua/vim/treesitter/query.lua:259: in function 'parse_query'
...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:104: in function 'normalise_query'
...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:161: in function 'parse_positions_from_string'
...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'func'
...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:156: in function <...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:155>
[C]: in function 'xpcall'
...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:155: in function <...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:154>
Logs on the 2nd try (TSX): no additional logs, directly posts "No tests found".
I dug into the specific problem for neotest-jest and found it to be what looks like a breaking change in the javascript treesitter parser: https://github.com/nvim-neotest/neotest-jest/pull/100. I know there were some breaking highlighting changes in treesitter lately. Not sure if there were other breaking changes introduced as well.
This problem was not impacting my other projects that did not have any typescript/javascript within them but my neotest-jest adapter was also the very last one in the list. Not sure if adapter ordering could be the cause of @fnune's problem?
Placing neotest-python
first did allow the Python test discovery to succeed & let me run tests. But (1) the TypeScript discovery still failed, and (2) my Python tests didn't run until the TypeScript discovery part failed (which took a good 15 seconds).
Repeating the workaround in case it's helpful to others: pinning nvim-treesitter
to v0.9.1
fixes all these problems, but it would be nice to be able to update.
Looks like it a bug in neotest-jest
, which broke discovery for all other adaptors: updating neotest-jest
has made things work for me with treesitter
on v0.9.2
: https://github.com/nvim-neotest/neotest-jest/pull/100
NeoVim Version Output of
nvim --version
NVIM v0.8.2 Build type: Release LuaJIT 2.1.0-beta3 Compiled by runner@fv-az190-151Features: +acl +iconv +tui See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/share/nvim"
Run :checkhealth for more info
Describe the bug When try to show test us :NeotestSummary error occurs and no test function showed.
To Reproduce Please provide a minimal
init.lua
to reproduce which can be run as the following:You can edit the following example file to include your adapters and other required setup.
Steps to reproduce the behavior:
:NeotestSummary
Please provide example test files to reproduce.
Expected behavior Show all test function correctly
Logs
neotest.log
file instdpath("log")
orstdpath("data")
.log_level = vim.log.levels.DEBUG
in your neotest setup config.Additional context The code doesn't work on wsl but works fine in my arch linux.