Open Kindlewing opened 1 year ago
I've been wondering the same, @Kindlewing. What if the run
method could take a callback? We could use that to do whatever we wanted after running tests.
It would be really nice if it was possible to jump into the test output directly after running the test. Maybe I overlooked something inside the documentation, but I don't know how to jump into the output without an extra command. I have since written a :NtShow
custom command for this, but it would be really nice to just enter the output directly if I am running the test from code.
Just noticed that it would show test outputs if the test failed:
The option open_on_run
is ambiguous, making users expect the output to show after the run action, IMO. It can be easily done by just removing this line of code. But I believe that there must be a better way to solve that.
See #50; show_output or attach depending on the test job status.
See #50; show_output or attach depending on the test job status.
Update:
No problem directly with vim.loop
instead of plenary.job
(I guess vim.uv
is ok too):
local neotest = require("neotest")
neotest.setup({
adapters = {
require("neotest-go"),
require("neotest-rust")({ args = { "--no-capture" }, dap_adapter = "lldb" }),
},
status = { virtual_text = true },
output = { enabled = true, open_on_run = false },
consumers = {
attach_or_output = function(client)
local M = {}
function M.open(opts)
opts = opts or {}
local pos = neotest.run.get_tree_from_args(opts)
if pos and client:is_running(pos:data().id) then
neotest.run.attach()
else
neotest.output.open({ enter = true })
end
end
return M
end,
},
})
vim.api.nvim_create_user_command("NTestOutput", function()
neotest.run.run()
local handle
handle, _ = vim.loop.spawn(
"sleep",
{ args = { "3s" }, stdio = nil },
vim.schedule_wrap(function(_)
handle:close()
neotest.attach_or_output.open()
end)
)
end, {})
The custom consumer can choose a proper way to attach running or open results. But I always have to execute run and attach_or_output
sequentially.
I have tried to create a command combined with run
which executes attach_or_output
after sleeping one second using plenary.job
. But it failed on the coroutine callback to the open method.
I should see what I can do on run
's listeners
@yuchanns does this solve you issue? it open attach window first an then it disappears if the test is quick. Im looking for a way to make a consumer similar to overseer, but don't really understand how they achieve that
Is there a way to show test output when running the tests? Below is my config:
Keymap for running: