V13Axel / neotest-pest

Neotest adapter for Pest 2.0
MIT License
14 stars 5 forks source link

Just switched over from theutz's fork; erroring out when running any tests #5

Closed nexxai closed 5 months ago

nexxai commented 5 months ago

Hey, so I just switched over from theutz's original version to this fork but now when I try to run my tests (using this keymap: vim.keymap.set("n", "<leader>t", "<cmd>lua require('neotest').run.run()<cr>")), I get this error:

neotest-pest: ...s/nexxai/.local/share/nvim/lazy/neotest/lua/nio/init.lua:105: The coroutine failed with this message: 
...l/share/nvim/lazy/neotest-pest/lua/neotest-pest/init.lua:161: No test output file found! Should have been at: storage/app/junit-20240301-014550
stack traceback:
    [C]: in function 'error'
    ...l/share/nvim/lazy/neotest-pest/lua/neotest-pest/init.lua:161: in function 'results'
    ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:132: in function '_run_spec'
    ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:89: in function <...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:88>

I don't think I did anything different, I just updated the name of the form in my test.lua file:

test.lua

return {
  {
    "nvim-neotest/neotest",
    dependencies = {
      "V13Axel/neotest-pest",      -- changed this from theutz/neotest-pest
    },
    config = function()
      require("neotest").setup({
        adapters = {
          require("neotest-pest"),
        },
      })
    end,
  },
}

Anyone have any ideas as to what the problem might be? If I switch back to theutz's version, everything works.

One thing I noticed is that the plugin checks for the existence of vendor/bin/sail and if it's there, assumes Sail should be enabled. AFAIK, Sail is included with every Laravel app, whether you use it or not (it's in my vendor/bin folder but I do not use it) and so that check may need to be more robust? Not sure if that has anything to do with this, just saw the note in the README that says:

Which kind of feels like it's applicable here. I tried manually setting sail_enabled = false in the require("neotest-pest") config options, but that didn't seem to have an effect.

V13Axel commented 5 months ago

Hmm, I think you have a point regarding sail detection - at the moment it is just looking for vendor/bin/sail, when it seems like the adapter should probably try to be smarter about it. What I'd love to do is detect that sail is running, but that goes a tad outside my comprehension of lua just yet.

I think I'll start by updating it to look for docker-compose.yml as well, since that's not created by default.

I'm not 100% sure why at the moment, but it looks like setting non-callable values in the config isn't working. Instead though, you can set it as sail_enabled = function() return false end and it should work.


Also, bit of a side note/tip: Your keybind can be simplified to

vim.keymap.set('n', '<leader>tn', function() require('neotest').run.run() end)

So it runs code lua directly rather than calling the lua command to do it.

nexxai commented 5 months ago

Instead though, you can set it as sail_enabled = function() return false end and it should work.

This seems to have solved my issue, so thanks!

Just curious if you're aware of any reason why a passing test still shows in the gutter as failed:

Screenshot 2024-03-04 at 9 12 22 PM

This is definitely NOT a failure of your plugin it happened in the theutz's version too, but maybe you've see a similar issue in the past and know how to fix it? Doesn't really affect me, but would like to solve it if I can.

V13Axel commented 5 months ago

Hmm, that's interesting. I can't seem to replicate that in a local test with the same signature.

Does your neotest.log (usually at ~/.local/state/nvim/neotest.log) say anything when you try?

If not, try setting log_level = vim.log.levels.DEBUG, in neotest's config and see if anything seems relevant :sweat_smile:

nexxai commented 5 months ago

lmao - it's been doing that since I started teaching myself neovim 2-3 months ago. I just went to try it after your suggestion and now it works perfectly. Computers are fun.

V13Axel commented 5 months ago

Who knows what happened! Either way, glad it's working for ya! ¯\_(ツ)_/¯