vim-test / vim-test

Run your tests at the speed of thought

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dispatch truncates jest output

theTechGoose opened this issue · comments

Hey Guys,
I admit that I might be using this wrong. However, I have a quick question,
Is there any way to get the plugin to show error outputs when it fails?
Sometimes Jest fails because of a syntax error or typescript error, and all I get in the output is this:

image

When running in the terminal by using jest , I get this:

image

As you can see, the terminal output is much more helpful. I'm sure it's a setting I'm missing somewhere. Can someone shed a little light on this?

Hi Raphael

I'm not too familiar with jest but I get failure output whenever I run rspec (ruby test framework) or cypress.

Here's my configuration for neovim:

-- vim-test

vim.api.nvim_set_var(
    "test#strategy",
    {
        nearest = "basic",
        file = "dispatch",
        suite = "dispatch_background"
    }
)

vim.api.nvim_set_var("test#ruby#rspec#executable", "bundle exec rspec")

vim.api.nvim_set_keymap("n", "<Leader>x", ":TestNearest<CR>", default_map_opts)
vim.api.nvim_set_keymap("n", "<Leader>t", ":TestFile<CR>", default_map_opts)
vim.api.nvim_set_keymap("n", "<Leader>r", ":TestSuite<CR>", default_map_opts)
vim.api.nvim_set_keymap("n", "<Leader>e", ":TestLast<CR>", default_map_opts)
vim.api.nvim_set_keymap("n", "<Leader>l", ":TestVisit<CR>", default_map_opts)

Looking at the executable that gets run https://github.com/vim-test/vim-test/blob/master/autoload/test/javascript/jest.vim#L39-L45 it should just write to stdout in the same way you're expecting in the terminal

So assuming you have node_modules/.bin/jest in the current repository you're running tests in, I'd expect to see vim-test running with node_modules/.bin/jest

I'd also pay attention to your test strategy (where your tests run) and see if you get the correct output trying a different strategy

I think the problem is the dispatch test strategy, I really want the quickfix so that I can navigate the test output with vim itself, however I think that dispatch attempts to parse the output into a quickfix navigatable list. How can I set it to just post the output?

I haven't used the Dispatch strategy myself however in order to get it to populate the quickfix properly you will need a compiler for your test runner. I'd recommend taking a look at the solutions in #331

Thanks guys, I found a solution.
I just bound terminal testing to a a chord.

nnoremap <leader>td exec '! npx jest '.expand("%")

if the test fails to run I run the 'test debug' binding for a more verbose output. Not ideal however it works.