nvim-neotest / neotest-jest

MIT License
121 stars 80 forks source link

Add support for streaming results #43

Closed gugahoi closed 1 year ago

gugahoi commented 2 years ago

As per the recommendation in Neotest, it would be great to add streaming capabilities to this adapter. Since Jest supports a multitude of configuration variations out of the box, I hope this is not too complicated to do.

Ideally I'd like to see Neotest results auto update on save so that I can easily iterate changes. As it stands today I have to trigger that myself on each change however and it gets tiring quite fast. It ends up being easier to get another terminal with jest --watch running instead but I'd love to change that and get the feedback instantly, inside Neovim.

KostkaBrukowa commented 1 year ago

Hey! I've just added a PR that allows streaming results. You can take a look and see if it works for you. Open to any comments and opinions

gugahoi commented 1 year ago

Unfortunately I am having trouble getting this working. It seems to run the tests once but I don't get any updates. How can I troubleshoot/debug this?

neotest config

local neotest = require('neotest')

neotest.setup({
  icons = {
    running = "🏃",
    failed = "✖",
    passed = "✔",
    skipped = "⤵",
    unknown = ""
  },
  adapters = {
    require('neotest-jest')({
      jestCommand = "yarn test",
      cwd = function()
        return vim.fn.getcwd()
      end,
    }),
  },
})

vim.keymap.set('n', '<Space>tt', neotest.run.run)
vim.keymap.set('n', '<Space>ta', neotest.run.attach)
vim.keymap.set('n', '<Space>tf', function() neotest.run.run(vim.fn.expand('%')) end)
vim.keymap.set('n', '<Space>ts', neotest.summary.toggle)
vim.keymap.set("n", "<Space>tw", function() neotest.run.run({ jestCommand = 'yarn test --watch ' }) end)
vim.keymap.set('n', '[n', function() neotest.jump.prev() end)
vim.keymap.set('n', ']n', function() neotest.jump.next() end)

demo

asciicast

mmirus commented 1 year ago

Likewise, from my quick attempt running tests in watch mode the tests do seem to be rerun, but neotest does not update the summary or panel.