Giter Club home page Giter Club logo

neotest-elixir's People

Contributors

ajayvigneshk avatar halfdan avatar jfpedroza avatar scottming avatar soundmonster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

neotest-elixir's Issues

Unable to run test with asdf and system elixir

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:

  • install elixir, erlang and asdf
  • $ asdf global elixir system
    
  • $ asdf global erlang system
    
  • try to run some test using neotest plugin
  • the test is failed and output is the following
** (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.

Sigils in test names

Such tests are not recognized by the adapter:

  test ~s|text with quotes " and '| do

doctests

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!

Inconsistent behaviour when doctests are absent

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.

Multiline test names

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

image

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

Git submodule breaking plugin update

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!

How to debug tests?

πŸ—ΊοΈ Background

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)

πŸ› Problem

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)

πŸ—οΈ Configs

I use packer to install the plugin
  use({
    "nvim-neotest/neotest",
    requires = {
      {
        "jfpedroza/neotest-elixir",
      },
    }
  })
I installed `elixirls` with mason. Here is how I setup the debug adapter.
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"
    }
  },
}
Here is my neotest setup. The keymap for running the nearest test is working
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
  }
})

Umbrella projects

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?

Specify full path for umbrella projects

I 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.

No IO.inspect and the likes in the output window when assertion fails

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?

Screenshot 2022-11-21 at 15 17 24
Screenshot 2022-11-21 at 15 17 14

Nothing happens when running tests

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?

Is this repository still being maintained?

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.

Is it possible to run tests in IEx shell and then analyze the results for neotest?

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.

image

References:

Support projects without a JSON library in the dependencies

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

  • bit shift operators << which seems to be supported under a different module / syntax ref
  • string.unpack function for which all the existing options falls short in different ways
    • lua-struct does not return the bytes read as the second return value. Based on an issue comment on the repo, it seems like a simple change to return it.
    • lua-pack is not a drop-in replacement. returns values in base-2 formats 🀷🏻
    • lua-compat-5.3. This is possibly the only option that seemed to work, but it messes up with global values and that breaks somewhere in plenary code

Curious if there are any other ways / options to achive this

Tests with shortened do: blocks are not detected

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

Hey!!

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.