Adapter.is_test_file now finds the root and checks if mocha is installed on each test file.
Updated the tests (let me know if I should add some more).
Use nio.tests (neotest's own async library) instead of plenary.async.tests. This seems to fix the async tests that were failing on upsteam.
Removed the tests for recognising test files by folder names since they should not match anymore due to #8.
I tested on a monorepo with the following layout where app1/ has mocha installed and app2/ has jest installed. I do not use monorepos and have no experience with them so I hope this covers it.
Everything appears to work except that if I run the file or the single test as the first action, I get the following traceback:
Error executing vim.schedule lua callback: /Users/user/.vim-plug/neotest/lua/nio/tasks.lua:95: Async task failed without callback: The coroutine failed with this message:
/Users/user/.vim-plug/neotest/lua/nio/tasks.lua:95: Async task failed without callback: The coroutine failed with this message:
...vim-plug/neotest/lua/neotest/consumers/state/tracker.lua:47: attempt to index local 'tree' (a nil value)
stack traceback:
...vim-plug/neotest/lua/neotest/consumers/state/tracker.lua: in function 'is_test'
...vim-plug/neotest/lua/neotest/consumers/state/tracker.lua:155: in function 'update_running'
...r/.vim-plug/neotest/lua/neotest/consumers/state/init.lua:49: in function 'listener'
...ser/.vim-plug/neotest/lua/neotest/client/events/init.lua:51: in function <...ser/.vim-plug/neotest/lua/neotest/client/events/init.lua:47>
stack traceback:
[C]: in function 'error'
/Users/user/.vim-plug/neotest/lua/nio/tasks.lua:95: in function 'close_task'
/Users/user/.vim-plug/neotest/lua/nio/tasks.lua:117: in function 'step'
/Users/user/.vim-plug/neotest/lua/nio/tasks.lua:145: in function 'run'
...ser/.vim-plug/neotest/lua/neotest/client/events/init.lua:47: in function 'emit'
...user/.vim-plug/neotest/lua/neotest/client/state/init.lua:95: in function 'update_running'
/Users/user/.vim-plug/neotest/lua/neotest/client/init.lua:82: in function 'run_tree'
...rs/user/.vim-plug/neotest/lua/neotest/consumers/run.lua:73: in function 'func'
/Users/user/.vim-plug/neotest/lua/nio/tasks.lua:168: in function </Users/user/.vim-plug/neotest/lua/nio/tasks.lua:167>
stack traceback:
[C]: in function 'error'
/Users/user/.vim-plug/neotest/lua/nio/tasks.lua:95: in function 'close_task'
/Users/user/.vim-plug/neotest/lua/nio/tasks.lua:117: in function 'cb'
/Users/user/.vim-plug/neotest/lua/nio/tasks.lua:181: in function </Users/user/.vim-plug/neotest/lua/nio/tasks.lua:180>
This is the line where the tree is nil. I haven't been able to find an open/closed neotest issue that explains this.
I also get this traceback when using the upstream version of neotest-mocha so this might be a problem with what is passed to neotest or an issue with neotest itself. I do not get this issue with neotest-jest.
Strangely, if I open the summary before running the test, it runs as expected with no tracebacks...I'll try and spend some more time on the issue but it should not really be a blocker for this PR as the issue also exists in upstream neotest-mocha (at least on my machine).
This should fix nvim-neotest/neotest#105.
Summary of changes:
util.has_package_dependency
.Adapter.is_test_file
now finds the root and checks if mocha is installed on each test file.nio.tests
(neotest's own async library) instead ofplenary.async.tests
. This seems to fix the async tests that were failing on upsteam.I tested on a monorepo with the following layout where
app1/
has mocha installed andapp2/
has jest installed. I do not use monorepos and have no experience with them so I hope this covers it.Everything appears to work except that if I run the file or the single test as the first action, I get the following traceback:
This is the line where the tree is
nil
. I haven't been able to find an open/closed neotest issue that explains this.I also get this traceback when using the upstream version of neotest-mocha so this might be a problem with what is passed to neotest or an issue with neotest itself. I do not get this issue with neotest-jest.
Strangely, if I open the summary before running the test, it runs as expected with no tracebacks...I'll try and spend some more time on the issue but it should not really be a blocker for this PR as the issue also exists in upstream neotest-mocha (at least on my machine).