jfpedroza / neotest-elixir Goto Github PK
View Code? Open in Web Editor NEWNeotest adapter for Elixir
License: MIT License
Neotest adapter for Elixir
License: MIT License
I just setup elixir in neovim. Running tests with neotest works but debugging isn't working yet. I have test debugging working for C# but I'm guessing my dap setup could be bad? Or maybe it isn't what neotest-elixir expects?
I'm using the Gilded Rose to learn Elixir (source)
lua require('neotest').run.run({strategy = 'dap'})
errors with:
Adapter doesn't support chosen strategy.
neotest-elixir: ...are/nvim/site/pack/packer/start/neotest/lua/nio/init.lua:105: The coroutine failed with this message:
...ker/start/neotest/lua/neotest/client/strategies/init.lua:55: attempt to index local 'instance' (a nil value)
stack traceback:
...ker/start/neotest/lua/neotest/client/strategies/init.lua: in function 'run'
.../pack/packer/start/neotest/lua/neotest/client/runner.lua:129: in function '_run_spec'
.../pack/packer/start/neotest/lua/neotest/client/runner.lua:89: in function <.../pack/packer/start/neotest/lua/neotest/client/runner.lua:88>
Press ENTER or type command to continue
This neotest issue seems to suggest that this problem involved the neotest adapter (source)
use({
"nvim-neotest/neotest",
requires = {
{
"jfpedroza/neotest-elixir",
},
}
})
dap.adapters.mix_task = {
type = 'executable',
command = require("mason-core.package"):get_install_path()..'/bin/elixir-ls-debugger',
args = {}
}
dap.configurations.elixir = {
{
type = "mix_task",
name = "mix test",
task = 'test',
taskArgs = {"--trace"},
request = "launch",
startApps = true, -- for Phoenix projects
projectDir = "${workspaceFolder}",
requireFiles = {
"test/**/test_helper.exs",
"test/**/*_test.exs"
}
},
}
local neotest_ok, neotest = pcall(require, 'neotest')
if not neotest_ok then
return
end
local function keymap(key, cmd, description)
vim.keymap.set({"n", "v"}, key, "<cmd>"..cmd.."<cr>", { desc = description })
end
keymap("<leader>tcr", "lua require('neotest').run.run(vim.fn.expand('%'))", "[t]est [c]lass [r]un")
keymap("<leader>tcd", "lua require('neotest').run.run({vim.fn.expand('%'), strategy = 'dap'})", "[t]est [c]lass [d]ebug")
keymap("<leader>tr", "lua require('neotest').run.run()", "[t]est [r]un")
keymap("<leader>td", "lua require('neotest').run.run({strategy = 'dap'})", "[t]est [d]ebug")
keymap("<leader>tsr", "lua require('neotest').run.run({suite = true})", "[t]est [s]uite [r]un")
keymap("<leader>tsd", "lua require('neotest').run.run({suite = true, strategy = 'dap'})", "[t]est [s]uite [d]ebug")
keymap("<leader>tw", "lua require('neotest').summary.toggle()", "[t]est [w]indow")
local adapters = {}
if packer_plugins["neotest-dotnet"] and packer_plugins["neotest-dotnet"].loaded then
table.insert(adapters, require("neotest-dotnet"))
end
if packer_plugins["neotest-elixir"] and packer_plugins["neotest-elixir"].loaded then
table.insert(adapters, require("neotest-elixir"))
end
neotest.setup({
adapters = adapters,
diagnostic = {
enabled = true
}
})
Hello
Thank you for this awesome adapter.
I'm trying to integrate it into my workflow and here is the error I've found.
Steps to reproduce:
$ asdf global elixir system
$ asdf global erlang system
** (SyntaxError) /home/artur/.asdf/shims/mix:3:18: syntax error before: '.'
|
3 | exec /home/artur/.asdf/bin/asdf exec "mix" "$@" # asdf_allow: ' asdf '
| ^
(elixir 1.14.0) lib/code.ex:1245: Code.require_file/2
everything is OK if I specify elixir version from asdf and not the system one.
Hi,
I am using Lazy to load plugins into NVIM and I am getting no feedback when running
lua require("neotest").run.run()
Here is my NVIM config for testing. I had previously installed vim-test, but then saw the developer was moving to a new project, so I installed that instead.
return {
{
-- wrapper for running tests of different granularities You β’ Mon 22 May 09:55:56 2023 β’ comments and removes modules
-- 'vim-test/vim-test',
{
'nvim-neotest/neotest',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-treesitter/nvim-treesitter',
'antoinemadec/FixCursorHold.nvim',
'jfpedroza/neotest-elixir'
},
config = function()
require('neotest').setup({
adapters = {
require('neotest-elixir')
}
})
end
},
'jfpedroza/neotest-elixir',
}
}
When I attempt to run the tests, it does nothing and I see no running tests. I am running the tests inside a vanilla scaffolded phoenix project.
Should I see a popup on the screen with test results?
defmodule MyTest do
use ExUnit.Case
test inspect(&MyModule.hello/1) do
# ...
end
end
^Such tests are not found.
The same, but with interpolation, works okay:
test "#{inspect(&MyModule.hello/1)}" do
Hey there, thanks for the great plugin!
Bit in a hurry right now, so just wanted to let you know that it seems that doctests are not fully supported (not listed in test summary, no indicator in signs?)
Let me know if I can help with this!
Such tests are not recognized by the adapter:
test ~s|text with quotes " and '| do
If test name contains \n
symbols, then such tests are not found by the adapter:
test "new\nline" do
In case of multiline (heredoc strings), UI representation is not great:
test """
new
line
""" do
I suggest replacing new lines with spaces, as it is done in Elixir for tests with --trace
option https://github.com/elixir-lang/elixir/pull/11728/files
Creating an issue from the TODO item to have discussion
I explored if using the ETF format could be an option. There exists a lua parser for it. But sadly this seems to make use of lua 5.3 constructs which is very hard to get it working on neovim (lua 5.1). More specifically, the parser uses
<<
which seems to be supported under a different module / syntax refstring.unpack
function for which all the existing options falls short in different ways
Curious if there are any other ways / options to achive this
Hey, thanks for the plugin!
I'm getting "No tests found" when running from the root of an umbrella project, but running inside each app works, am i missing something?
Hi π
Firstly, thank you so much for this plugin. It's what made me switch over from vim-test
to neotest
. π
Not sure if this question is a better fit here or in the neotest repo, but I don't see the output of IO.inspect
(or IO.puts
FWIW) on the test output
window when some assertion fails. Maybe I have the wrong expectations for the output? Missing a configuration?
If you don't have much time, I'd happily become a maintainer.
I want to add more tests to make maintenance of this repository easier. Additionally, I would like to remove support for mix_test_interactive because neotest's watch feature is really great.
In the example test file below, "test 1" is detected, but "test 2" is not. As soon as you convert "test 2" to a full do/end block, it then is detected. Convert "test 1" to a do: block, and it is no longer detected.
describe "my tests" do
test "test 1" do
assert true
end
test "test 2", do: assert false
end
Hi there!
This commit: a9b61bb
broke the plugin updating automatically for me, as the submodule was not getting updated correctly by git. I fixed it manually by going into ~/.local/share/nvim/lazy/neotest-elixir
and running git submodule update iex-unit
, which seems to have set everything straight. Is there any other way to reference that submodule in a way that won't break installs?
Thanks!
First of all, thank you very much for your work, which has given me a new experience in testing elixir in nvim. But I don't know if you have the same feeling that doing Unit Testing in elixir is much slower than in other languages, I know it's not caused by neotest or Lua.
The main reason is that every time you run a mix test
you need to start the whole app, whereas if we just run the test in iex
, it would be much faster.
Here is a project I generated with mix new elixir_demo
, you can see that even the simplest project that is brand new takes 1.5
seconds to run each test using the command line, whereas with iex it just takes 0.015
seconds, which is a 100x improvement, and if we could do that, then developing elixir projects in Nvim would be a superb experience.
mix test
? - Questions / Help - Elixir Programming Language ForumI noticed, that if I have opened an umbrella project, and I'm in the root of it, then tests are launched using not full paths.
Let's say we have the following structure:
apps/
foo/
test/
foo_test.exs
bar/
test/
bar_test.exs
... # other projects
and when I ask to run tests for foo_test.exs
, then the following command is executed:
mix test test/foo_test.exs
and mix tries to find the file in all the projects and reports these messages for every umbrella project:
Paths given to "mix test" did not match any directory/file: test/foo_test.exs
==> bar
it would be great if for umbrella projects the following command is executed:
mix apps/foo/test/foo_test.exs
Such approach would increase the speed of running tests.
Some time ago, module A
had doctests, but now it doesn't have them and doctest A
instruction is still in tests.
When I run tests for the whole file, then everything is green.
If I rerun test only for doctest, then it becomes red. Output is the following:
Excluding tags: [:test]
Including tags: [line: "4"]
All tests have been excluded.
Finished in 0.03 seconds (0.03s async, 0.00s sync)
23 tests, 0 failures, 23 excluded
Randomized with seed 487001
If I rerun tests for the whole file, then everything is green again.
You may ask why I rerun tests for doctests :) If another test in that file fails, and I run tests for the whole file, then doctest becomes red as well! I try to rerun doctests and consistently see it as red in neovim.
Expected behaviour: consider doctest instructions without tests as successful.
Hey! I just started looking into the Neotest library and was about to start working on an elixir adapter for it. Figured I'd do a search and found you had just begun one!
I'd love to help out, what all is left/is there a list of things you have left to finish?
The idea is to read the file that is used by ExUnit to write failed tests, so next time when you open summary of tests, you can already see failed tests even though they were run from the CLI.
https://github.com/elixir-lang/elixir/blob/927b10df80ee1c1c7396e68efe00d06bc3e80420/lib/mix/lib/mix/tasks/test.ex#L751-L767
Yo:
not sure if this is a problem with this plugin or neotest per se.
On a fresh compile step, test running can hang for a longgggggggg time with no indication that stuff is compiling.
I have no idea what to suggest here but I think it's kind of a problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.