Neotest adapter for Elixir
Last updated Apr 11, 2026
48
Stars
12
Forks
10
Issues
0
Stars/day
Attention Score
11
Language breakdown
Lua 53.9%
Elixir 46.1%
โธ Files
click to expand
README
neotest-elixir
Neotest adapter for Elixir
Installation
Using packer:
use({
"nvim-neotest/neotest",
requires = {
...,
"jfpedroza/neotest-elixir",
}
config = function()
require("neotest").setup({
...,
adapters = {
require("neotest-elixir"),
}
})
end
})
Configuration
You can optionally specify some settings:
require("neotest").setup({
adapters = {
require("neotest-elixir")({
-- The Mix task to use to run the tests
-- Can be a function to return a dynamic value.
-- Default: "test"
mixtask = {"mycustom_task"},
-- Other formatters to pass to the test command as the formatters are overridden
-- Can be a function to return a dynamic value.
-- Default: {"ExUnit.CLIFormatter"}
extra_formatters = {"ExUnit.CLIFormatter", "ExUnitNotifier"},
-- Extra test block identifiers
-- Can be a function to return a dynamic value.
-- Block identifiers "test", "feature" and "property" are always supported by default.
-- Default: {}
extrablockidentifiers = {"testwithmock"},
-- Extra arguments to pass to mix test
-- Can be a function that receives the position, to return a dynamic value
-- Default: {}
args = {"--trace"},
-- Command wrapper
-- Must be a function that receives the mix command as a table, to return a dynamic value
-- Default: function(cmd) return cmd end
postprocesscommand = function(cmd)
return vim.iter({{"env", "FOO=bar"}, cmd}):flatten():totable()
end,
-- Delays writes so that results are updated at most every given milliseconds
-- Decreasing this number improves snappiness at the cost of performance
-- Can be a function to return a dynamic value.
-- Default: 1000
write_delay = 1000,
-- The pattern to match test files
-- Default: "_test.exs$"
testfilepattern = ".test.exs$",
-- Function to determine whether a directory should be ignored
-- By default includes root test directory and umbrella apps' test directories
-- Params:
-- - name (string) - Name of directory
-- - rel_path (string) - Path to directory, relative to root
-- - root (string) - Root directory of project
filterdir = function(name, relpath, root)
return rel_path == "test"
or rel_path == "lib"
or vim.startswith(rel_path, 'test/')
or vim.startswith(rel_path, 'lib/')
end,
}),
}
})
extra_args are also supported, so you can use them to specify other arguments to mix test:
require("neotest").run.run({vim.fn.expand("%"), extra_args = {"--formatter", "ExUnitNotifier", "--timeout", "60"}}))
Integration with Elixir watchers
The adapter supports mixtestinteractive to watch and run tests. Simply set mix_task to test.interactive.
Caveats: When you save a file, there won't be any indicator that the tests are running again.
TODO
- [ ] Add integration with
mix-test.watch
Development
In tests/sample_proj there is an Elixir project with to test that the adapter works
๐ More in this category