NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1693350652
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/nix/store/62nlxbqim2rgahbid2g7q5aryvzayycm-neovim-unwrapped-0.9.5/share/nvim
"
Run :checkhealth for more info
Describe the bug
In a multi-language repo, the wrong adapter can be used if only one of the adapters matches the root directory, but other adapters would match the file you want to test. For example, I have both neotest-go and neotest-vim-test enabled, and a repository with both go and typescript files. The root of the repository has a go.mod, thus making neotest-go match as an adapter for the directory, When I try to run the typescript test (which I want to be handled by the neotest-vim-test adapater), it tries to use the neotest-go adapter because I'm guessing neotest-vim-test doesn't match any directory pattern as it can be used for so many different langauges? As a result, I get the "No tests found" error because neotest-go doesn't know how to handle the typescript file, but since it's named file.test.ts instead of file_test.go, I would expect the neotest-vim-test adapter to be used.
To Reproduce
Please provide a minimal init.lua to reproduce which can be run as the following:
nvim --clean -u minimal.lua
You can edit the following example file to include your adapters and other required setup.
vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))
local lazypath = "/tmp/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
"nvim-neotest/neotest",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
-- Install adapters here
"nvim-neotest/neotest-vim-test",
"nvim-neotest/neotest-go",
"vim-test/vim-test"
},
config = function()
-- Install any required parsers
require("nvim-treesitter.configs").setup({
ensure_installed = {},
})
require("neotest").setup({
-- Add adapters to the list
adapters = {
require("neotest-vim-test")({
ignore_file_types = { "go" },
}),
require("neotest-go")({
experimental = {
test_table = true,
},
}),
},
})
end,
})
Steps to reproduce the behavior:
Start with a multi-language repo, like a repo that has both a go.mod and a package.json in the root. For example, I ran into this on a public repo I'm working on: https://github.com/grafana/loki-release
If using the above repo, run npm install and go mod tidy, then open the file actions/should-release/__tests__/github.test.ts
Put cursor on the first test, and run :lua require('neotest').run.run(), and see No tests found. If you turn on debug logs, you'll see it reporting that it's using the neotest-go adapter as that one matches the root directory
Change minimal.lua to remove neotest-go, and go through the same steps. The test will run fine
Expected behavior
I would expect the neotest-vim-test adapter to be used, since it should match the file github.test.ts, while neotest-go should not match github.test.ts
NeoVim Version Output of
nvim --version
Describe the bug In a multi-language repo, the wrong adapter can be used if only one of the adapters matches the root directory, but other adapters would match the file you want to test. For example, I have both
neotest-go
andneotest-vim-test
enabled, and a repository with both go and typescript files. The root of the repository has ago.mod
, thus makingneotest-go
match as an adapter for the directory, When I try to run the typescript test (which I want to be handled by theneotest-vim-test
adapater), it tries to use theneotest-go
adapter because I'm guessingneotest-vim-test
doesn't match any directory pattern as it can be used for so many different langauges? As a result, I get the "No tests found" error becauseneotest-go
doesn't know how to handle the typescript file, but since it's namedfile.test.ts
instead offile_test.go
, I would expect theneotest-vim-test
adapter to be used.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:
go.mod
and apackage.json
in the root. For example, I ran into this on a public repo I'm working on: https://github.com/grafana/loki-releasenpm install
andgo mod tidy
, then open the fileactions/should-release/__tests__/github.test.ts
:lua require('neotest').run.run()
, and seeNo tests found
. If you turn on debug logs, you'll see it reporting that it's using theneotest-go
adapter as that one matches the root directoryminimal.lua
to removeneotest-go
, and go through the same steps. The test will run fineExpected behavior I would expect the
neotest-vim-test
adapter to be used, since it should match the filegithub.test.ts
, whileneotest-go
should not matchgithub.test.ts
Logs