neotest-elixir icon indicating copy to clipboard operation
neotest-elixir copied to clipboard

Test is marked as failed when it succeded

Open rlopzc opened this issue 1 year ago • 9 comments

Not sure why. I have a multiline describe do.. block. I attach a screenshot.

image

It also succeeds in the console

Here's my setup:

require("neotest").setup({
  adapters = {
    require("neotest-elixir")({}),
  }
})

vim.keymap.set('n', '<leader>tr', function() require('neotest').run.run() end)
vim.keymap.set('n', '<leader>ta', function() require("neotest").run.run(vim.fn.expand("%")) end)
vim.keymap.set('n', '<leader>td', function() require("neotest").run.run({strategy = "dap"}) end)
vim.keymap.set('n', '<leader>tp', function() require("neotest").output_panel.toggle() end)

rlopzc avatar Jul 31 '24 00:07 rlopzc

Does the describe name have any special characters or a dynamic value (string interpolation)?

jfpedroza avatar Jul 31 '24 00:07 jfpedroza

  describe "Condition 1.
    payor override = HHSC
    TMHP Managed Care not active with line of business = STAR STAR+PLUS STAR Kids or MMP
    TMHP Service Authorization NPI & Provider matches Roster Payor" do
    test "no alert if payor override != HHSC", %{resident_0: context} do

This is the example

rlopzc avatar Jul 31 '24 00:07 rlopzc

Btw, do you know how to run the test but not open the floating window? I'm using the output_panel

rlopzc avatar Jul 31 '24 00:07 rlopzc

It seems I completely forgot about describes when I implemented multiline test names. I don't have many of those in my work project, so I hadn't noticed. Dynamic test names aren't supported either.

Btw, do you know how to run the test but not open the floating window? I'm using the output_panel

See :h neotest.Config.output.

jfpedroza avatar Jul 31 '24 00:07 jfpedroza

I have another similar case for this test: https://github.com/rudiejd/exercism-exercises/blob/f68783e18579f361e63ce875e4b197c55b3f51be/elixir/captains-log/test/captains_log_test.exs#L33

There is no dynamic test name, but the start with NCC- test was displayed as failing when in reality other tests were failing. When I expand the results, I can see that the start with NCC- test wasn't the one failing. image image

Strangely, the output file shows this test as succeeding:

{
  "id": "/home/jd/exercism/elixir/captains-log/test/captains_log_test.exs::random_ship_registry_number::start with \"NCC-\"",
  "output": "/tmp/nvim.jd/zMpzmd/28/test_output_122641753",
  "status": "passed",
  "seed": 0,
  "errors": []
}

And the output is just the generic Test passed output. So I think that something might be going wrong in between the results and the display of tests to the user

rudiejd avatar Nov 14 '24 16:11 rudiejd

Probably related to the quotes in the test name.

jfpedroza avatar Nov 14 '24 16:11 jfpedroza

Good call! That fixes it.

I'm not sure whether the quote issue is an issue with the neotest-elixir adapter or with the neotest code upstream. The results file indicate that the test is passing, but neotest.state.status_counts indicates that removing the quotes adds one successful test

rudiejd avatar Nov 14 '24 16:11 rudiejd

Probably neotest-elixir. Special characters need to be handled explicitly on the Neovim lua side of the adapter.

jfpedroza avatar Nov 14 '24 20:11 jfpedroza

I'll open a separate issue for this one then, and maybe take a crack at it later :+1:

rudiejd avatar Nov 15 '24 01:11 rudiejd