Check mocha is installed (support monorepos), fix tests #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).