nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.44k stars 123 forks source link

[BUG] watch.toggle broke in update #457

Open whytewolf opened 2 months ago

whytewolf commented 2 months ago

NeoVim Version

NVIM v0.10.1
Build type: RelWithDebInfo
LuaJIT 2.1.1725453128
Run "nvim -V1 -v" for more info

Describe the bug require("neotest").watch.toggle(vim.fn.expand("%")) is throwing a strack trace after an update

E5108: Error executing lua: ...tewolf/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:100: Async task failed without callback: The coroutine failed with this message: 
.
...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua:36: attempt to call field 'supports_method' (a table value)
stack traceback:
    ...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua: in function 'get_valid_client'
    ...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua:51: in function 'get_lsp_client'
    ...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua:110: in function 'watch'
    ...e/nvim/lazy/neotest/lua/neotest/consumers/watch/init.lua:160: in function 'func'
    ...tewolf/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:173: in function <...tewolf/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:172>
stack traceback:
    [C]: in function 'error'
    ...tewolf/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:100: in function 'close_task'
    ...tewolf/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:122: in function 'step'
    ...tewolf/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:150: in function 'toggle'
    /home/whytewolf/.config/nvim/lua/ww/plugins/neotest.lua:88: in function </home/whytewolf/.config/nvim/lua/ww/plugins/neotest.lua:87>

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-neotest/nvim-nio",
    "nvim-lua/plenary.nvim",
    "antoinemadec/FixCursorHold.nvim",
    "nvim-treesitter/nvim-treesitter",
    "nvim-neotest/neotest-python",
    "nvim-neotest/neotest-plenary",
    "nvim-neotest/neotest-vim-test",
  },
  config = function()
    require("neotest").setup({
      adapters = {
        require("neotest-python")({
          dap = { justMyCode = false },
          args = { "--cov=src", "--log-level", "DEBUG" },
          runner = "pytest",
      }),
        require("neotest-plenary"),
        require("neotest-vim-test")({
          ignore_file_types = { "python", "vim", "lua" },
        }),
      },
    })
  end,
})

Steps to reproduce the behavior:

  1. load a test file
  2. :lua require("neotest").watch.toggle(vim.fn.expand("%")) a. nothing happens, no sidebar nothing
  3. :lua require("neotest").watch.toggle(vim.fn.expand("%")) again
  4. get error.

Please provide example test files to reproduce.

Expected behavior watch sidebar pops up showing tests.

Additional context this setup was working last week. and no other changes have taken place besides an update.

whytewolf commented 2 months ago

ok, I was thinking of a different functionality... but this did have the error.

https://github.com/nvim-neotest/neotest/pull/456 does look like it fixes the error seen.

rcasia commented 1 month ago

This issue is solved as https://github.com/nvim-neotest/neotest/pull/456 is already merged.