neotest
neotest copied to clipboard
[BUG] No test found
NeoVim Version
Output of nvim --version
NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az190-151
Features: +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:
nvim --clean -u minimal.lua
You can edit the following example file to include your adapters and other required setup.
-- ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))
vim.opt.termguicolors = true
-- append test directory
local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))
-- install packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
vim.cmd("packadd packer.nvim")
install_plugins = true
end
local packer = require("packer")
packer.init({
package_root = test_dir .. "/pack",
compile_path = test_dir .. "/plugin/packer_compiled.lua",
})
packer.startup(function(use)
use("wbthomason/packer.nvim")
use({
"nvim-neotest/neotest",
requires = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/neotest-go",
-- Your other test adapters here
},
config = function()
-- get neotest namespace (api call creates or returns namespace)
local neotest_ns = vim.api.nvim_create_namespace("neotest")
vim.diagnostic.config({
virtual_text = {
format = function(diagnostic)
local message =
diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
return message
end,
},
}, neotest_ns)
require("neotest").setup({
-- your neotest config here
log_level = vim.log.levels.DEBUG,
adapters = {
require("neotest-go"),
},
})
end,
})
if install_plugins then
packer.sync()
end
end)
vim.cmd([[
command! NeotestSummary lua require("neotest").summary.toggle()
command! NeotestFile lua require("neotest").run.run(vim.fn.expand("%"))
command! Neotest lua require("neotest").run.run(vim.fn.getcwd())
command! NeotestNearest lua require("neotest").run.run()
command! NeotestDebug lua require("neotest").run.run({ strategy = "dap" })
command! NeotestAttach lua require("neotest").run.attach()
command! NeotestOutput lua require("neotest").output.open()
]])
Steps to reproduce the behavior:
- Open neovim
-
:NeotestSummary
Please provide example test files to reproduce.
Expected behavior Show all test function correctly
Logs
- Wipe the
neotest.log
file instdpath("log")
orstdpath("data")
. - Set
log_level = vim.log.levels.DEBUG
in your neotest setup config. - Reproduce the issue.
- Provide the new logs.
ERROR | 2024-01-13T22:35:22Z+0800 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:57 | Child process is waiting for input at startup. Aborting.
ERROR | 2024-01-13T22:35:22Z+0800 | ...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:311 | Couldn't find positions in path /home/saltfish/Coding/Project/GalaxyEmpireWeb/master/services/userservice/user-service_test.go ...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:117: attempt to call field 'get_lang' (a nil value)
stack traceback:
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:117: in function 'get_parse_root'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:160: in function 'parse_positions_from_string'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'discover_positions'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:302: in function <...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:266>
[C]: in function 'xpcall'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:266: in function '_update_positions'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:319: in function <...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:317>
ERROR | 2024-01-13T22:35:22Z+0800 | ...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:311 | Couldn't find positions in path /home/saltfish/Coding/Project/GalaxyEmpireWeb/master/services/accountservice/account-service_test.go ...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:117: attempt to call field 'get_lang' (a nil value)
stack traceback:
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:117: in function 'get_parse_root'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:160: in function 'parse_positions_from_string'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'discover_positions'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:302: in function <...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:266>
[C]: in function 'xpcall'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:266: in function '_update_positions'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:319: in function <...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:317>
ERROR | 2024-01-13T22:35:22Z+0800 | ...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:311 | Couldn't find positions in path /home/saltfish/Coding/Project/GalaxyEmpireWeb/master/models/model_test.go ...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:117: attempt to call field 'get_lang' (a nil value)
stack traceback:
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:117: in function 'get_parse_root'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:160: in function 'parse_positions_from_string'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'discover_positions'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:302: in function <...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:266>
[C]: in function 'xpcall'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:266: in function '_update_positions'
...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:319: in function <...ig/pack/packer/start/neotest/lua/neotest/client/init.lua:317>
Additional context The code doesn't work on wsl but works fine in my arch linux.