Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Test assertions get reported to the wrong line #467

Open
natdm opened this issue Nov 4, 2024 · 0 comments
Open

[BUG] Test assertions get reported to the wrong line #467

natdm opened this issue Nov 4, 2024 · 0 comments
Assignees

Comments

@natdm
Copy link

natdm commented Nov 4, 2024

NeoVim Version

NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1727870382
Run "nvim -V1 -v" for more info

Describe the bug

This is using the Jest runner. I'm unsure if this is a Jest runner bug or a neotest bug. Willing to migrate if needed.

The tests will run fine, and report failures. The failures however are on the wrong test.

In the screenshots below, you can see that the first test passes, but has the expect errors reported on it that needed to be reported to the test below. This reports the same in the qf window as well. On top of that, the test with the actual failures does fail, but does not get any reports back for the expects, as they're placed in the first test.

If you read the errors reported back, you'll see they're for the wrong expects (one is for length, and the other is for a snapshot).

Screenshot 2024-11-04 at 6 02 58 AM
Screenshot 2024-11-04 at 6 03 14 AM

In this screenshot, I changed the assertion on line 137 to read toHaveLength(4) instead of the correct length of 3, and that error gets reported on line 103.

Screenshot 2024-11-04 at 6 06 40 AM

To Reproduce
Please provide a minimal init.lua to reproduce which can be run as the following:

nvim --clean -u minimal.lua

You can edit the following example file to include your adapters and other required setup.

vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))

local lazypath = "/tmp/lazy/lazy.nvim"

if not 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)

require("lazy").setup({
  "nvim-neotest/neotest",
  dependencies = {
    "nvim-lua/plenary.nvim",
    "nvim-treesitter/nvim-treesitter",
    -- Install adapters here
  },
  config = function()
    -- Install any required parsers
    require("nvim-treesitter.configs").setup({
      ensure_installed = {},
    })

    require("neotest").setup({
      -- Add adapters to the list
      adapters = {},
    })
  end,
})

Steps to reproduce the behavior:

  1. Working on test files, but have provided logs. If you'd like to pair over zoom/meet, let me know and we can work on that.

Expected behavior
Test failures get reported to the correct lines

Logs
neotest.log

Additional context
N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants