elixir-tools / elixir-tools.nvim

Neovim plugin for Elixir
MIT License
395 stars 29 forks source link

Running all tests in a phoenix project are all faillings #217

Closed worming004 closed 3 weeks ago

worming004 commented 3 weeks ago

First, thanks for this plugin. Running file per file is working very well

What am I trying to accomplish

I have habits to run all tests in a project. In other language like go and c#, I can do that with require("neotest").run.run(vim.fn.getcwd()) command.

What I am expecting

I am expecting to see tests running succefull

What I am experiencing

All tests are failling with error

error: syntax error before: '='
    │
  1 │ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>RegistrationLiveTest do
    │             ^
    │
    └─ _build/dev/lib/phoenix/priv/templates/phx.gen.auth/registration_live_test.exs:1:13

How to reproduce

Make a file ~/.config/nvim-elixir/init.lua file with the following content. It is just install minimal config with lazy.nvim

 local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"

if not (vim.uv or 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)

local lazy = require("lazy")

lazy.setup(
  {
    "nvim-neotest/neotest",
    event = "VeryLazy",
    dependencies = {
      "nvim-neotest/nvim-nio",
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter",
      "jfpedroza/neotest-elixir",
    },
    config = function()
      require("neotest").setup({
        adapters = {
          require("neotest-elixir")
        },
      })
    end,
  }
)

vim.keymap.set("n", "<space>tra", function() require("neotest").run.run(vim.fn.getcwd()) end, { desc = "run all tests" })
vim.keymap.set("n", "<space>trf", function() require("neotest").run.run() end, { desc = "run file tests" })

Then, create a new phoenix project and run tests with the following commands :

mix phx.new helloworld
cd helloworld
mix deps.get
mix ecto.create # Should be optional
mix ecto.migrate # Should be optional
mix test # All tests should work
NVIM_APPNAME=nvim-elixir nvim # start neovim with the init.lua from earlier
:e test/helloworld_web/controllers/page_controller_test.exs # just to open a file with tests
:Neotest summary # to see all tests
:lua require("neotest").run.run(vim.fn.getcwd()) # all tests are failling
:lua require("neotest").run.run() # file tests are succesful

Notes

I tried to understand how elixir-tools.nvim works, but I was unable to find any clues of what could be the origin

worming004 commented 3 weeks ago

My gosh, I created this issue convinced I am writing on https://github.com/jfpedroza/neotest-elixir. Google redirect to this repo when searching for neovim elixir tests.

My bad, I am closing this bug as it is intended for another repository